@abtnode/blocklet-services 1.16.46-beta-20250709-123154-c05c363c → 1.16.47-beta-20250710-073736-01b9c1bc
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
package/api/index.js
CHANGED
|
@@ -88,6 +88,17 @@ const createMCPRoutes = require('./routes/mcp');
|
|
|
88
88
|
const bodyParser = require('./middlewares/body-parser');
|
|
89
89
|
const federatedUtil = require('./util/federated');
|
|
90
90
|
|
|
91
|
+
process.on('unhandledRejection', (reason, promise) => {
|
|
92
|
+
// If it's a SQLite “database is locked” error, just log and continue
|
|
93
|
+
if (reason && (reason.code === 'SQLITE_BUSY' || reason.message.includes('SQLITE_BUSY'))) {
|
|
94
|
+
console.error('SQLite busy, skipping exit:', reason.message);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
console.error('Unhandled Rejection at:', promise, 'reason:', reason);
|
|
99
|
+
process.exit(1);
|
|
100
|
+
});
|
|
101
|
+
|
|
91
102
|
const agent = new http.Agent();
|
|
92
103
|
|
|
93
104
|
// remove items that are already in the official whitelist
|
package/api/libs/image.js
CHANGED
|
@@ -278,7 +278,7 @@ const processAndRespond = (req, res, cacheDir, getSrc, ext, sendOptions = { maxA
|
|
|
278
278
|
})
|
|
279
279
|
.catch((err) => {
|
|
280
280
|
logger.error('image filter failed', { error: err, params, url: req.url });
|
|
281
|
-
const status = getStatusFromError(err);
|
|
281
|
+
const status = err.message?.includes('unsupported image format') ? 400 : getStatusFromError(err);
|
|
282
282
|
if (params.e) {
|
|
283
283
|
res.status(status).send(`Image service error: ${err.message}`);
|
|
284
284
|
} else {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{J as E,j as e,ak as c,E as A,bm as h,b6 as g,bn as L,at as I,$ as N}from"./vendor-mui-core-p6jGoroc.js";import{r as m}from"./vendor-react-x2lQvn4m.js";import{T as y,H as j}from"./vendor-ux-TkkDR0Gn.js";import{A as O}from"./config-
|
|
1
|
+
import{J as E,j as e,ak as c,E as A,bm as h,b6 as g,bn as L,at as I,$ as N}from"./vendor-mui-core-p6jGoroc.js";import{r as m}from"./vendor-react-x2lQvn4m.js";import{T as y,H as j}from"./vendor-ux-TkkDR0Gn.js";import{A as O}from"./config-Bzod-0Gd.js";import{a as b}from"./page-header-CiDBkMEP.js";import{m as v,f as R,c as o,h as T}from"./index-CDq77s86.js";import{S as Y}from"./layout-BcCpT3Sj.js";import{S as P}from"./step-actions-Cmo-e1Kn.js";import{S as k}from"./button-DEodgJFI.js";import"./vendor-utils-CtD44yV-.js";import"./vendor-hooks-zCCbpt45.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-BndcJjQO.js";import"./content-layout-BFy-gp0u.js";import"./use-mobile-DpkDXDwi.js";function D({onNext:a=()=>{}}){const C=E(),{t:n,locale:p}=y(),[i,l]=m.useState(!1),[S,d]=m.useState(""),{blocklet:r}=v();m.useEffect(()=>{const t=R.findServiceFromMeta(r.meta,o.NODE_SERVICES.AUTH);d(t?.config?.whoCanAccess||o.WHO_CAN_ACCESS.ALL)},[r]);const f=async t=>{let s=o.ACCESS_POLICY_PUBLIC;t===o.WHO_CAN_ACCESS.ALL?s=o.ACCESS_POLICY_PUBLIC:t===o.WHO_CAN_ACCESS.INVITED?s=o.ACCESS_POLICY_INVITED_ONLY:t===o.WHO_CAN_ACCESS.OWNER?s=o.ACCESS_POLICY_OWNER_ONLY:t===o.WHO_CAN_ACCESS.ADMIN&&(s=o.ACCESS_POLICY_ADMIN_ONLY);try{l(!0),await T.updateBlockletSecurityRule({input:{did:r.meta.did,data:{id:o.SECURITY_RULE_DEFAULT_ID,accessPolicyId:s}}}),l(!1)}catch(_){l(!1),j.error(_.message)}},x=async t=>{i||(d(t.target.value),await f(t.target.value))},u={marginRight:4,fontSize:18,verticalAlign:"text-bottom",color:C.palette.text.secondary};return e.jsxs(H,{children:[e.jsx(c,{className:"header",children:e.jsx(b,{title:n("blocklet.config.access.title"),subTitle:n("blocklet.config.access.description")})}),e.jsx(A,{component:"fieldset",children:e.jsx(h,{name:"inherit",value:S,onChange:x,children:O.map(t=>e.jsxs(c,{sx:{mb:2},children:[e.jsx(g,{value:t.value,control:e.jsx(L,{size:"small",color:"primary"}),label:e.jsxs("span",{style:{display:"flex",alignItems:"center",position:"relative"},children:[e.jsx(t.icon,{style:u}),e.jsx("span",{style:{marginTop:2},children:t.title[p]})]})}),e.jsx(c,{className:"tip",children:t.description[p]})]},t.value))})}),e.jsx(P,{mt:8,disabled:i,blocklet:r,onStartNow:()=>a("complete"),children:e.jsx(k,{loading:i,variant:"contained",disabled:i,onClick:()=>a(),children:n("setup.continue")})})]})}D.propTypes={onNext:N.func};const H=I(Y)`
|
|
2
2
|
height: 100%;
|
|
3
3
|
overflow-y: auto;
|
|
4
4
|
.header {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{$ as F,j as l,p as Tt,at as it,ak as oe,J as qt,T as je,O as Gt,b6 as Jr,C as Qr,I as _o,c1 as No,X as Ao,c9 as ya,dK as ba,aP as Do,F as xa,G as Vn,bE as wa,bF as Sa,bG as Ea,bC as ka,aX as Mo,Z as Ta,aO as ja,cT as Oa,cU as Ca,bA as Ia,c0 as Ra,M as Zr,am as Bo,aq as Pa,b1 as ut,b7 as La,dq as _a,a9 as Fo,ad as $o,aV as Na,aj as Uo,V as kn,a1 as Aa,bv as qo,v as Wo,aU as Da,ar as Kt,c6 as Ma,c5 as Ba,bY as Si,Y as Ei,ah as Fa,du as $a,U as Ua,P as qa,S as Wa,ai as za,an as zo,H as ki,aI as Va,dL as Ka}from"./vendor-mui-core-p6jGoroc.js";import{r as q,g as ei,u as Ga,i as Ha,e as Vo,p as Xa,a as Ut,d as Ya,f as Cn,j as Ja}from"./vendor-react-x2lQvn4m.js";import{r as ti,S as Qa,s as Ko,A as Za}from"./item-
|
|
1
|
+
import{$ as F,j as l,p as Tt,at as it,ak as oe,J as qt,T as je,O as Gt,b6 as Jr,C as Qr,I as _o,c1 as No,X as Ao,c9 as ya,dK as ba,aP as Do,F as xa,G as Vn,bE as wa,bF as Sa,bG as Ea,bC as ka,aX as Mo,Z as Ta,aO as ja,cT as Oa,cU as Ca,bA as Ia,c0 as Ra,M as Zr,am as Bo,aq as Pa,b1 as ut,b7 as La,dq as _a,a9 as Fo,ad as $o,aV as Na,aj as Uo,V as kn,a1 as Aa,bv as qo,v as Wo,aU as Da,ar as Kt,c6 as Ma,c5 as Ba,bY as Si,Y as Ei,ah as Fa,du as $a,U as Ua,P as qa,S as Wa,ai as za,an as zo,H as ki,aI as Va,dL as Ka}from"./vendor-mui-core-p6jGoroc.js";import{r as q,g as ei,u as Ga,i as Ha,e as Vo,p as Xa,a as Ut,d as Ya,f as Cn,j as Ja}from"./vendor-react-x2lQvn4m.js";import{r as ti,S as Qa,s as Ko,A as Za}from"./item-D9OLZ5b9.js";import{n as yt,a as ni,e as Go,T as wt,I as bt,a8 as el,r as tl,B as Kn,H as Gn,at as Ti,m as Xt,o as Ho,$ as qn,E as Xo,c as nl,C as rl,aR as il}from"./vendor-ux-TkkDR0Gn.js";import{_ as ln,f as $t,c as ol,c8 as sl,a_ as al,bO as Yo,c9 as ll,bK as cl,ca as ul,cb as dl,U as hl,M as Bt,bl as fl,$ as Jo,aC as pl,cc as ml,C as gl,cd as vl,Y as Hn,ce as Qo,b8 as Zo,k as Xn,a3 as ji,cf as yl,an as Mr,ac as bl,cg as xl,ch as wl,ci as In,cj as Oi,a$ as Sl}from"./index-CDq77s86.js";import{j as Ci,o as El,T as kl,L as Tl,P as jl}from"./vendor-arcblock-BndcJjQO.js";import{u as Ii}from"./launch-result-message-gmDOMo-e.js";import{a as es}from"./page-header-CiDBkMEP.js";import{e as vt,B as Ol,C as Zt,J as Yn,D as Ri,R as ts,Q as Cl,a8 as Il,A as Rl,o as rr,U as Pl,am as Ll,an as _l,ao as Nl,a as yn,S as Al,b as Dl}from"./vendor-utils-CtD44yV-.js";import{f as Br}from"./index-DBs9Ljax.js";import{e as Ml}from"./engine-CbuJOouR.js";import{u as Bl,C as Fl}from"./config-space-bJO1Pq2d.js";import{R as ir}from"./logo-uploader-CnbjQmUt.js";import{S as $l}from"./index-CV2-Ra10.js";import{a as ns,h as Ul,w as ql,f as Wl,b as zl,d as Vl,e as Kl,M as Gl}from"./index-E_Fpmc4w.js";import{k as Tn,a as Hl,b as Xl,u as rs,g as Yl,q as Jl}from"./vendor-hooks-zCCbpt45.js";import{g as Ql}from"./get-safe-url-70dNOHyP.js";import{r as Zl}from"./index-MGxe3V9B.js";import{r as ec}from"./cloneDeep-wCAABKRh.js";import{u as ri}from"./useLocalStorage-DHCQcCRn.js";import{v as Pi}from"./index-VGO-dEle.js";import{u as tc}from"./session-CvQ97dDY.js";import{W as nc}from"./did-address-BdvYNOBf.js";import{a as Li}from"./api-CpYSt0CS.js";import{v as rc,e as ic}from"./util-CNKleiqU.js";import{u as is}from"./use-mobile-B8-JPkft.js";import{C as oc}from"./content-layout-BFy-gp0u.js";import{C as sc,D as ac,a as lc}from"./connect-to-CWHsYUA6.js";import{d as or}from"./search-4YYphs0l.js";const Lf="blocklet-add-component-registry",_f="server-add-registry",Nf=e=>`resource-${e}-add-registry`;function os(e){const{info:t}=ln();return q.useMemo(()=>!e||!e.docker?.image||e.docker?.image&&e.docker?.runBaseScript?!0:window.blocklet?window.blocklet.enableDocker&&window.blocklet.enableDockerNetwork:t.enableDocker&&t.enableDockerNetwork,[e,t])}function ss({disabled:e=!1,children:t,onConfirm:r}){return q.useEffect(()=>{if(e)return()=>{};const i=s=>{s.code==="Enter"&&(s.metaKey===!0||s.ctrlKey===!0)&&(s.preventDefault(),s.stopPropagation(),r())};return document.addEventListener("keydown",i),()=>{document.removeEventListener("keydown",i)}},[e,r]),t}ss.propTypes={disabled:F.bool,children:F.any.isRequired,onConfirm:F.func.isRequired};function as({onContinue:e,nextDisabled:t=!1,launching:r=!1,texts:i={listenName:"",launchingText:"",buttonNext:""},description:s=""}){const[n,o]=q.useState(!1);return l.jsxs(l.Fragment,{children:[l.jsx(cc,{children:l.jsxs(ss,{disabled:t,onConfirm:e,children:[l.jsx("div",{className:"eula-trigger",onClick:()=>o(a=>!a),children:i.listenName}),l.jsx(yt,{disabled:t,color:"primary",variant:"contained",className:"next-button",onClick:e,children:r?l.jsxs(l.Fragment,{children:[l.jsx(Tt,{size:14}),i.launchingText]}):i.buttonNext})]})}),l.jsx(ni,{open:n,title:i.listenName,onClose:()=>o(!1),children:s})]})}as.propTypes={onContinue:F.func.isRequired,nextDisabled:F.bool,launching:F.bool,description:F.any,texts:F.object};const cc=it.div`
|
|
2
2
|
margin: 0 auto;
|
|
3
3
|
display: flex;
|
|
4
4
|
justify-content: space-between;
|
|
@@ -217,7 +217,7 @@ A valid navigation id is should follow the rules of javascript variables, such a
|
|
|
217
217
|
- foo123
|
|
218
218
|
|
|
219
219
|
see detail in https://www.npmjs.com/package/is-var-name
|
|
220
|
-
`),B=c.string().trim().min(1).custom(V=>{if(N(V)>m.MAX_TITLE_LENGTH)throw new Error(`title length should not exceed ${m.MAX_TITLE_LENGTH} (see: https://www.npmjs.com/package/cjk-length)`);return V}).meta({className:"TTitle"});ie.titleSchema=B;const M=c.string().trim().min(3).max(160).meta({className:"TDescription"});ie.descriptionSchema=M;const re=c.string().trim().min(3).max(20).messages({"*":"Title length must be between 3 and 20 characters"}).meta({className:"TInstallBlockletTitle"});ie.installBlockletTitleSchema=re;const Z=c.string().trim().min(3).max(80).messages({"*":"Description length must be between 3 and 80 characters"}).meta({className:"TInstallBlockletDescription"});ie.installBlockletDescriptionSchema=Z;const z=c.string().uri({scheme:["http","https"],allowRelative:!0}).allow("").custom((V,ae)=>V.includes(u.WELLKNOWN_BLOCKLET_LOGO_PATH)?ae.message(`logo url should not include ${u.WELLKNOWN_BLOCKLET_LOGO_PATH}`):V).meta({className:"TLogo"});ie.logoSchema=z;const W=c.string().trim().min(1),H=W.meta({className:"TMountPoint"}).custom((V,ae)=>(0,_.isValidUrlPath)(V)?V:ae.message(`mountPoint cannot contain such characters space $*+~()'"!:@\\`));ie.mountPointSchema=H;const A=W.meta({className:"TUpdateMountPoint"}).custom(V=>(0,_.default)(V));ie.updateMountPointSchema=A;const X=c.string().custom(V=>((0,C.validateName)(V),V)).meta({className:"TBlockletName"});ie.blockletNameSchema=X;const $=[],he=c.string().trim().min(1).max(50).required().custom((V,ae)=>V.startsWith("BLOCKLET")&&!$.includes(V)?ae.message("Env name can not start with BLOCKLET_"):V.startsWith("COMPONENT")?ae.message("Env name can not start with COMPONENT_"):V.startsWith("ABTNODE")?ae.message("Env name can not start with ABTNODE_"):/[^\w]/.test(V)?ae.message('Env name can include only numbers or letters or "_"'):V).meta({className:"TEnvironmentName",unknownType:"any"});ie.environmentNameSchema=he;const Oe=c.object({name:he.required(),description:c.string().trim().required(),default:c.string().optional().allow("").default(""),required:c.boolean().default(!1),secure:c.boolean().default(!1),validation:c.string().optional(),shared:c.boolean().default(V=>V.secure?!1:void 0)}).custom((V,ae)=>V.secure&&V.default?ae.message(`Cannot declare default value for secure env ${V.name}`):V).meta({className:"TEnvironment",unknownType:"any"});ie.environmentSchema=Oe;const K=c.object({dev:c.string().trim().min(1),e2eDev:c.string().trim().min(1),preFlight:c.string().trim().min(1),preInstall:c.string().trim().min(1),postInstall:c.string().trim().min(1),preStart:c.string().trim().min(1),postStart:c.string().trim().min(1),preStop:c.string().trim().min(1),preUninstall:c.string().trim().min(1),preConfig:c.string().trim().min(1)}).rename("pre-flight","preFlight").rename("pre-install","preInstall").rename("post-install","postInstall").rename("pre-start","preStart").rename("post-start","postStart").rename("pre-stop","preStop").rename("pre-uninstall","preUninstall").rename("pre-config","preConfig").optional().meta({className:"TScripts",unknownType:"any"});ie.scriptsSchema=K;const we=c.object({name:c.string().required().trim(),config:c.object().optional().default({})}).unknown(!0).meta({className:"TService",unknownType:"any"});ie.serviceSchema=we;const de=c.object({type:c.string().trim(!0).min(1).required(),path:c.string().required(),meta:c.object({vcType:c.string(),payable:c.boolean(),params:c.array().items({name:c.string().required().trim(),description:c.string().required().trim()})})}).meta({className:"TEndpoint",unknownType:"any"});ie.endpointSchema=de;const Le=c.string().trim().custom((V,ae)=>{const me=V.split("/").filter(Boolean);return me.length===0?ae.message("cacheable path must be a valid pathname that is not /"):`/${me.join("/")}`}).meta({className:"TPathPrefix",unknownType:"any"});ie.cacheableSchema=Le;const ve=c.object({type:c.string().lowercase().valid(...m.BLOCKLET_INTERFACE_TYPES).required(),name:c.string().trim().required(),path:c.string().trim().default("/"),prefix:c.string().trim().min(1).default(m.BLOCKLET_DYNAMIC_PATH_PREFIX),containerPort:c.number().port().optional(),hostIP:c.string().trim().ip({version:["ipv4","ipv6"]}).optional(),protocol:c.string().lowercase().valid(...m.BLOCKLET_INTERFACE_PROTOCOLS).default("http"),port:c.alternatives().try(c.string().uppercase().default(m.BLOCKLET_DEFAULT_PORT_NAME),c.object({internal:c.string().uppercase().required(),external:c.number().port().required()})).default(m.BLOCKLET_DEFAULT_PORT_NAME),cacheable:c.array().items(Le).unique(),services:c.array().items(we).unique("name"),endpoints:c.array().items(de).unique("type"),pageGroups:c.array().items(c.string().min(1).max(255).trim()).unique(),proxyBehavior:c.string().valid("service","direct").default("service").optional()}).meta({className:"TInterface",unknownType:"any"});ie.interfaceSchema=ve;const _e=c.alternatives().try(c.string().required(),c.object({url:c.string().uri({scheme:["http","https","file"]}).required(),name:X.required(),version:c.alternatives().try(c.string().valid("latest"),c.semverRange().valid())}),c.object({store:c.string().uri({scheme:["http","https"]}).required(),name:X.required(),version:c.alternatives().try(c.string().valid("latest"),c.semverRange().valid()).default("latest")})),Pe=c.object({platform:c.string().valid(...m.BLOCKLET_PLATFORMS).optional(),interpreter:c.string().valid("binary","node","blocklet").default("node"),source:_e,args:c.array().items(c.string()).optional().default([])}).meta({className:"TEngine",unknownType:"any"});ie.engineSchema=Pe;const He=c.object({name:c.string().min(1).required(),email:c.string().email({tlds:!1}).optional(),url:c.string().uri().optional()}).meta({className:"TPerson",unknownType:"any"});ie.personSchema=He;const et=c.object({tarball:c.alternatives().try(c.string().uri(),c.string()).required(),integrity:c.string().required(),size:c.number().optional()}).meta({className:"TDist",unknownType:"any"});ie.distSchema=et;const ht=c.object({downloads:c.number().integer().greater(-1),star:c.number().default(0),purchases:c.number().default(0)}).meta({className:"TStats",unknownType:"any"});ie.statsSchema=ht;const te={source:c.alternatives().try(c.object({url:c.alternatives().try(c.string().uri(),c.array().items(c.string().uri()).min(1)).required(),version:c.alternatives().try(c.string().valid("latest"),c.semverRange().valid())}),c.object({store:c.string().uri({scheme:["http","https"]}),name:X.required(),version:c.alternatives().try(c.string().valid("latest"),c.semverRange().valid()).default("latest")})).required(),required:c.boolean(),title:B,description:M,mountPoint:H,name:X},Ne=(V,ae)=>c.object(V).custom((me,Ce)=>!ae&&me.source&&me.source.name&&!me.source.store?Ce.message(`missing 'store' in source of component ${me.name}`):me),ye=Ne(te).meta({className:"TComponent",unknownType:"any"});ie.componentSchema=ye;const Be=Ne(te,!0),jt=({checkStore:V}={})=>{const ae=[ye,Be];return c.array().items(V?ae[0]:ae[1]).optional().default([])},Ot=c.object({type:c.string().required(),name:c.string().required(),signer:c.string().required(),pk:c.string().required(),created:c.string().isoDate().required(),sig:c.string().required(),excludes:c.array().items(c.string()).optional(),appended:c.array().items(c.string()).optional(),delegatee:c.string(),delegateePk:c.string(),delegation:c.string()}).meta({className:"TSignature",unknownType:"any"});ie.signatureSchema=Ot;const Me=["en","zh","fr","ru","ar","es","de","pt","ja","hi"],Ct={id:c.string().custom(R),title:c.alternatives().try(c.string().min(1).max(m.MAX_TITLE_LENGTH),c.object().min(1).pattern(c.string().valid(...Me),c.string().min(1).max(m.MAX_TITLE_LENGTH))).required(),description:c.alternatives().try(c.string().min(1).max(m.MAX_DESCRIPTION_LENGTH),c.object().min(1).pattern(c.string().valid(...Me),c.string().min(1).max(m.MAX_DESCRIPTION_LENGTH))),link:c.alternatives().try(c.string().custom(w),c.object().min(1).pattern(c.string().valid(...Me),c.string().custom(w))),component:c.string().min(1),section:c.array().items(c.string().min(1)).single(),role:c.array().items(c.string().min(1)).single(),icon:c.string().min(1),visible:c.boolean()},Et=c.object({...Ct,items:c.array().items(c.object({...Ct}).rename("child","component"))}).rename("child","component").meta({className:"TNavigationItem",unknownType:"any"});ie.navigationItemSchema=Et;const _t=c.array().items(Et).unique((V,ae)=>V.id&&ae.id?V.id===ae.id:!1).meta({className:"TNavigation",unknownType:"any"});ie.navigationSchema=_t;const Ye=c.object({background:c.alternatives().try(c.string().min(1),c.object({header:c.string().min(1),footer:c.string().min(1),default:c.string().min(1)}).min(1))}).meta({className:"TTheme",unknownType:"any"});ie.themeSchema=Ye;const It=c.object({whoCanAccess:c.string().valid("owner","invited","all"),profileFields:c.array().items(c.string().valid("fullName","email","avatar","phone")).unique(),ignoreUrls:c.array().items(c.string().min(1)),allowSwitchProfile:c.boolean(),blockUnauthenticated:c.boolean(),blockUnauthorized:c.boolean()}).options({stripUnknown:!0}).meta({className:"TAuthConfig",unknownType:"any"});ie.authConfigSchema=It;const Nt=c.object({type:c.string().trim().min(1).required(),description:c.string().trim().min(1)}),at=c.object({did:c.DID().trim().required(),type:c.string().trim().min(1).required(),public:c.boolean()}).meta({className:"TResourceBundle",unknownType:"any"});ie.resourceBundleSchema=at;const qe=c.array().items(c.object({type:c.string().trim().min(1).max(128).pattern(/^(?!blocklet\.)[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/).message('Event type must be in format of "[noun.]verb" like "post.published" or "post.comment.published", and prefix "blocklet." is reserved').required(),description:c.string().trim().min(1).max(256).required()})).unique("type").meta({className:"TEvent",unknownType:"any"});ie.eventsSchema=qe;const tt={did:c.DID().trim().required(),version:c.semver().valid().required(),name:c.string().optional(),description:M.required(),group:c.string().valid(...m.BLOCKLET_GROUPS),main:c.string().trim(),title:B.optional().allow(""),logo:c.string().trim().optional(),specVersion:c.semver().valid().gte("1.0.0").optional(),author:He.optional(),contributors:c.array().items(He).optional(),maintainers:c.array().items(He).optional(),community:c.string().uri().optional().allow("").default(""),documentation:c.string().uri().optional().allow("").default(""),homepage:c.string().uri().optional().allow("").default(""),license:c.string().optional().allow("").default(""),support:c.alternatives().try(c.string().uri(),c.string().email({tlds:!1})).optional(),nftFactory:c.DID().optional().allow("").default(""),payment:c.object({price:c.array().max(1).items(c.object({value:c.number().greater(0).required(),address:c.DID().required()})).default([]),share:c.array().max(4).items(c.object({name:c.string().required(),address:c.DID().required(),value:c.number().greater(0).max(1).required()})).default([]).custom(V=>{if(V.length===0)return V;const ae=V.reduce((me,Ce)=>me+Ce.value,0);if(ae!==1)throw new Error(`Invalid blocklet payment share config: total share must be 1, got ${ae}`);return V},"invalid blocklet share"),componentPrice:c.array().items(c.object({parentPriceRange:c.array().items(c.number()).custom((V,ae)=>V.length!==2?ae.message("length of range should be 2"):V[0]<0?ae.message("the first value should not less than 0 in range"):V[1]<=V[0]?ae.message("the second value should greater than the first value in range"):V),type:c.string().valid("fixed","percentage").required(),value:c.number().greater(0).required()})).single()}).default({price:[],share:[]}),keywords:c.alternatives().try(c.string().trim().min(1),c.array().items(c.string().min(1))).optional(),tags:c.alternatives().try(c.string().trim().min(1),c.array().items(c.string().min(1))).optional(),gitHash:c.string().optional().allow(""),repository:c.alternatives().try(c.string().min(1),c.object({type:c.string().valid("git","https","svn").required(),url:c.string().uri().required(),directory:c.string()})).optional(),timeout:c.object({start:c.number().min(10).max(600),script:c.number().min(1).max(1800)}).default({start:60}),requirements:c.object({abtnode:c.semverRange().valid(),server:c.semverRange().valid(),os:c.alternatives().try(c.string().valid("*",...m.BLOCKLET_PLATFORMS),c.array().items(c.string().valid(...m.BLOCKLET_PLATFORMS)).min(1)),cpu:c.alternatives().try(c.string().valid("*",...m.BLOCKLET_ARCHITECTURES),c.array().items(c.string().valid(...m.BLOCKLET_ARCHITECTURES)).min(1)),fuels:c.array().items(c.object({endpoint:c.string().trim().required(),address:c.string().trim(),value:c.string().trim().required(),reason:c.string().trim().required()})),nodejs:c.semverRange().valid()}).default({server:m.BLOCKLET_LATEST_REQUIREMENT_SERVER,os:"*",cpu:"*",nodejs:"*"}),interfaces:c.array().items(ve).unique("name").custom((V,ae)=>{if(V.filter(ee=>ee.type===m.BLOCKLET_INTERFACE_TYPE_WEB).length>1)return ae.message(`Only one ${m.BLOCKLET_INTERFACE_TYPE_WEB} interface can be declared`);const Ce=V.filter(ee=>ee.type===m.BLOCKLET_INTERFACE_TYPE_WELLKNOWN);for(const ee of Ce)if(!ee.prefix.startsWith(D))return ae.message(`Wellknown path prefix must start with: ${D}`);return V}).default([]),environments:c.array().items(Oe).default([]).optional().custom((V,ae)=>{if(V&&V.length){const me=V.filter((Ce,ee)=>V.findIndex(O=>O.name===Ce.name)!==ee);if(me.length)return ae.message(`find duplicate environment names ${me.map(Ce=>Ce.name).join(", ")}`)}return V}),scripts:K,capabilities:c.object({clusterMode:c.boolean(),didSpace:c.string().valid(...Object.values(m.BLOCKLET_APP_SPACE_REQUIREMENT)).optional(),navigation:c.boolean().default(!0),serverless:c.boolean().optional(),component:c.boolean(),sitemap:c.boolean().optional(),mcp:c.boolean().optional()}).default({}),files:c.array().items(c.string().trim()).optional(),resource:c.object({exportApi:c.string().trim(),bundles:c.array().items(at),types:c.array().items(Nt).max(10)}),engine:c.alternatives().try(Pe,c.array().items(Pe)).optional(),screenshots:c.array().items(c.string().min(1)).optional().default([]),videos:c.array().items(c.string().pattern(/^https:\/\/(www\.)?(youtube\.com|youtu\.be|vimeo\.com)\/[\w\-/?&=]+/).message("Each video URL must be a valid YouTube or Vimeo link")).max(3).optional(),logoUrl:c.string().optional().allow(""),dist:et.optional(),stats:ht.optional(),htmlAst:c.any().optional(),path:c.string().optional(),signatures:c.array().items(Ot).optional(),lastPublishedAt:c.string().isoDate().optional().allow(null),components:jt(),navigation:_t,theme:Ye,copyright:c.object({owner:c.string().min(1),year:c.alternatives().try(c.string(),c.number())}),bundleName:c.string(),bundleDid:c.DID().trim(),storeId:c.string(),events:qe.optional()},ot=c.object(tt).options({stripUnknown:!0,noDefaults:!1}).meta({className:"TBlockletMeta",unknownType:"any"});ie.blockletMetaSchema=ot;const mt=(V,{ensureFiles:ae=!1,ensureDist:me=!1,ensureComponentStore:Ce=!0,ensureName:ee=!1,skipValidateDidName:O=!1,...Ie}={})=>((!V||!s.default.existsSync(V))&&(ae=!1),c.object({...tt,owner:c.object({avatar:c.string().optional(),did:c.DID().trim().required(),fullName:c.string().trim().required(),email:c.string().optional().allow(null).empty("").default("")}).optional(),logo:ae?c.file().trim().exists({baseDir:V}).optional():c.string().trim().optional(),files:c.array().items(ae?c.file().exists({baseDir:V,canSkip:(Re,Fe)=>[m.BLOCKLET_ENTRY_FILE,m.BLOCKLET_BUNDLE_FILE].includes(Fe)||(0,a.default)(Fe)}):c.string().trim()).optional(),dist:me?et.required():et.optional(),components:jt({checkStore:Ce}),name:ee?c.string().optional():c.string().required(),egress:c.boolean().optional().default(!0),docker:j.dockerSchema}).options({stripUnknown:!0,noDefaults:!1,...Ie}).rename("children","components").custom((Re,Fe)=>{const{did:p,name:x,docker:k}=Re;if(k){const{image:U,dockerfile:ne,network:le}=k;if(!U&&!ne)return Fe.message("Image or dockerfile must be set");if(U&&ne)return Fe.message("Image and dockerfile cannot be set at the same time");if(le)return Fe.message("ExportPorts and network cannot be set at the same time");ne&&(Re.files||(Re.files=[]),Re.files.push(ne))}let L;if((0,f.isValid)(p))try{return(0,C.validateNewDid)(p),Re}catch(U){L=U}if(x){(0,C.validateName)(x,{checkDid:!O});const U=(0,E.default)(x);return U!==p?Fe.message(`The did of name "${x}" should be "${U}"`):Re}return L?Fe.message(L.message):Re}));return ie.createBlockletSchema=mt,ie.default={blockletNameSchema:X,componentSchema:ye,endpointSchema:de,serviceSchema:we,createBlockletSchema:mt,interfaceSchema:ve,environmentSchema:Oe,environmentNameSchema:he,scriptsSchema:K,personSchema:He,distSchema:et,titleSchema:B,descriptionSchema:M,logoSchema:z,navigationSchema:_t,themeSchema:Ye,mountPointSchema:H,updateMountPointSchema:A,authConfigSchema:It,resourceBundleSchema:at,installBlockletTitleSchema:re,installBlockletDescriptionSchema:Z,eventsSchema:qe,Joi:c},ie}var pt={},io;function cu(){if(io)return pt;io=1;var e=pt&&pt.__importDefault||function(h){return h&&h.__esModule?h:{default:h}};Object.defineProperty(pt,"__esModule",{value:!0}),pt.setService=pt.findService=pt.getDefaultServiceConfig=pt.getServiceConfig=void 0;const t=e(ec),r=vs(),i={},s=h=>{i[h.name]={validate:h.schema.validate.bind(h.schema),defaultConfig:h.default}};pt.setService=s,s({name:"auth",schema:r.authConfigSchema,default:{}});const n=h=>{if(!h)throw new Error("service name should not be empty");const u=i[h];if(!u)throw new Error(`service ${h} does not exist`);return u},o=(h,u,{validate:f}={})=>{const j=n(h),m=(0,t.default)(u||{}),{value:E,error:S}=j.validate(m);if(f&&S)throw new Error(`Invalid blocklet service config: ${S.details.map(C=>C.message).join(", ")}`);return E};pt.getServiceConfig=o;const a=h=>{const{defaultConfig:u}=n(h);return u};pt.getDefaultServiceConfig=a;const d=(h,u)=>{const f=[u];return(h||[]).find(j=>f.includes(j.name))};return pt.findService=d,pt.default={getServiceConfig:o,getDefaultServiceConfig:a,findService:d,setService:s},pt}var oo;function uu(){if(oo)return Vt;oo=1,Object.defineProperty(Vt,"__esModule",{value:!0}),Vt.fixAndValidateService=Vt.validateMeta=void 0;const e=vs(),t=cu(),r=s=>(!s.interfaces||!s.interfaces.length||s.interfaces.forEach(n=>{n.services&&n.services.length&&n.services.forEach(o=>{o.config=(0,t.getServiceConfig)(o.name,o.config,{validate:!0})})}),s);Vt.fixAndValidateService=r;const i=(s,{ensureFiles:n=!1,ensureDist:o=!1,ensureComponentStore:a=!0,ensureName:d=!1,skipValidateDidName:h=!1,schemaOptions:u={}}={})=>{const f=(0,e.createBlockletSchema)(null,{ensureFiles:n,ensureDist:o,ensureComponentStore:a,ensureName:d,skipValidateDidName:h,...u}),{value:j,error:m}=f.validate(s);if(m)throw new Error(`Invalid blocklet meta: ${m.details.map(E=>E.message).join(", ")}`);return j};return Vt.validateMeta=i,Vt.default=i,Vt}var so;function du(){return so||(so=1,function(e){var t=kt&&kt.__createBinding||(Object.create?function(w,R,B,M){M===void 0&&(M=B);var re=Object.getOwnPropertyDescriptor(R,B);(!re||("get"in re?!R.__esModule:re.writable||re.configurable))&&(re={enumerable:!0,get:function(){return R[B]}}),Object.defineProperty(w,M,re)}:function(w,R,B,M){M===void 0&&(M=B),w[M]=R[B]}),r=kt&&kt.__setModuleDefault||(Object.create?function(w,R){Object.defineProperty(w,"default",{enumerable:!0,value:R})}:function(w,R){w.default=R}),i=kt&&kt.__importStar||function(){var w=function(R){return w=Object.getOwnPropertyNames||function(B){var M=[];for(var re in B)Object.prototype.hasOwnProperty.call(B,re)&&(M[M.length]=re);return M},w(R)};return function(R){if(R&&R.__esModule)return R;var B={};if(R!=null)for(var M=w(R),re=0;re<M.length;re++)M[re]!=="default"&&t(B,R,M[re]);return r(B,R),B}}(),s=kt&&kt.__importDefault||function(w){return w&&w.__esModule?w:{default:w}};Object.defineProperty(e,"__esModule",{value:!0}),e.fixService=e.fixInterfaces=e.parsePerson=e.formatPerson=e.fixName=e.fixTags=e.fixPerson=e.fixKeywords=e.fixFiles=e.fixRepository=e.fixRequired=void 0;const n=s(cl),o=i(Kc()),a=Yo(),d=uu();Object.defineProperty(e,"fixService",{enumerable:!0,get:function(){return d.fixAndValidateService}});const h=gs(),u=(w,R)=>{w.description||(w.description=`Blocklet from ${R}`),w.version||(w.version=a.BLOCKLET_DEFAULT_VERSION)};e.fixRequired=u;const f=w=>{if(w.repository&&(typeof w.repository=="string"&&(w.repository={type:"git",url:w.repository}),w.repository.url)){const R=o.fromUrl(w.repository.url);R&&(w.repository.url=R.getDefaultRepresentation()==="shortcut"?R.https():R.toString())}};e.fixRepository=f;const j=w=>{Array.isArray(w.files)?w.files&&(w.files=w.files.filter(R=>!(!R||typeof R!="string"))):delete w.files};e.fixFiles=j;const m=w=>{typeof w.keywords=="string"&&(w.keywords=w.keywords.split(/,\s+/)),w.keywords&&!Array.isArray(w.keywords)?delete w.keywords:w.keywords&&(w.keywords=w.keywords.filter(R=>!(typeof R!="string"||!R)))};e.fixKeywords=m;const E=w=>{typeof w.tags=="string"&&(w.tags=w.tags.split(/,\s+/)),w.tags&&!Array.isArray(w.tags)?delete w.tags:w.tags&&(w.tags=w.tags.filter(R=>!(typeof R!="string"||!R)))};e.fixTags=E;const S=(w,R)=>(w.author&&(w.author=R(w.author)),["maintainers","contributors"].forEach(B=>{Array.isArray(w[B])&&(w[B]=w[B].map(R))}),w),C=w=>{if(!w)return"";if(typeof w=="string")return w;const R=w.name||"",B=w.url||w.web,M=B?` (${B})`:"",re=w.email||w.mail,Z=re?` <${re}>`:"";return R+Z+M};e.formatPerson=C;const _=w=>{if(typeof w!="string")return w;const R=w.match(/^([^(<]+)/),B=w.match(/\(([^)]+)\)/),M=w.match(/<([^>]+)>/),re={};return R&&R[0].trim()&&(re.name=R[0].trim()),M&&([,re.email]=M),B&&([,re.url]=B),re};e.parsePerson=_;const N=w=>(S(w,C),S(w,_),w);e.fixPerson=N;const D=(w,R=!0)=>{if(Array.isArray(w.interfaces)||(w.interfaces=[]),w.interfaces.length)return w.interfaces.forEach(Z=>{Z.type===a.BLOCKLET_INTERFACE_TYPE_WEB&&(Z.protocol="http")}),w;const M=(0,n.default)(w,"capabilities.dynamicPathPrefix",!0)?a.BLOCKLET_DYNAMIC_PATH_PREFIX:"/",re=({type:Z="web",name:z,path:W="/",protocol:H="http",port:A=a.BLOCKLET_DEFAULT_PORT_NAME})=>{w.interfaces.push({type:Z,name:z,path:W,prefix:M,port:A,protocol:H})};return[a.BLOCKLET_INTERFACE_PUBLIC].forEach(Z=>{w[Z]&&re({name:Z,path:w[Z]})}),Array.isArray(w.exposeServices)&&w.exposeServices.forEach(Z=>{re({type:"service",name:Z.protocol,protocol:Z.protocol,port:{internal:`BLOCKLET_${Z.protocol}_PORT`.toUpperCase(),external:Z.port}})}),R&&(delete w.publicUrl,delete w.adminUrl,delete w.configUrl,delete w.docUrl,delete w.exposeServices,w.capabilities&&delete w.capabilities.dynamicPathPrefix),w};e.fixInterfaces=D;const c=w=>{const{did:R}=w;try{(0,h.validateNewDid)(R),w.name=R}catch{}return w};e.fixName=c,e.default={fixRequired:u,fixRepository:f,fixFiles:j,fixKeywords:m,fixPerson:N,fixTags:E,fixName:c,formatPerson:C,parsePerson:_,fixInterfaces:D,fixService:d.fixAndValidateService}}(kt)),kt}var hu=du();function ys({owner:e,locale:t}){return l.jsxs(oe,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.fullName,e.did?l.jsx(Go,{sx:{lineHeight:"initial","&::before":{content:'"("'},"&::after":{content:'")"'}},did:e.did,compact:!0,size:14,locale:t}):null]})}ys.propTypes={owner:F.object.isRequired,locale:F.string.isRequired};const fu="install-blocklet-from-URL",bs=()=>{const[e,t]=ri(fu,"[]",{raw:!0}),r=s=>{const n=s.trim(),o=JSON.parse(e),a=o.findIndex(d=>d===n);a!==0&&(a>0&&o.splice(a,1),o.length>=10&&o.splice(9),o.unshift(n),t(JSON.stringify(o)))},i=s=>{if(!s)return;const n=JSON.parse(e),o=s.trim(),a=n.findIndex(d=>d===o);a>-1&&(n.splice(a,1),t(JSON.stringify(n)))};return{urls:e?JSON.parse(e):[],addUrlRecord:r,removeUrlRecord:i}};function xs({value:e="",onValueChange:t=()=>{},children:r=null,helperText:i=""}){const{urls:s,removeUrlRecord:n}=bs(),o=(a,d)=>{a.preventDefault(),a.stopPropagation(),n(d)};return l.jsxs(oe,{children:[l.jsx(No,{freeSolo:!0,options:s,inputValue:e,onInputChange:(a,d)=>{t(d)},disableClearable:!0,popupIcon:null,renderInput:a=>Ut.cloneElement(r,{...a}),renderOption:(a,d)=>q.createElement(Ao,{...a,key:d,secondaryAction:l.jsx(_o,{edge:"end","aria-label":"delete",onClick:h=>o(h,d),children:l.jsx(ya,{})})},l.jsx(ba,{role:void 0,dense:!0,sx:{paddingLeft:0,paddingRight:30,"&:hover":{backgroundColor:"transparent"}},children:l.jsx(Do,{primary:d,sx:{"& span":{display:"block",width:"100%",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"}}})})),slotProps:{listbox:{sx:{maxHeight:300,overflow:"auto"}}}}),l.jsx(xa,{style:{margin:0},children:i})]})}xs.propTypes={onValueChange:F.func,children:F.node,value:F.string,helperText:F.string};function ws({onClick:e}){const{t}=wt();return l.jsx(ul,{title:t("launchBlocklet.withoutWallet"),icon:l.jsx(bt,{icon:dl,fontSize:"1em"}),onClick:e})}ws.propTypes={onClick:F.func.isRequired};function Ss({defaultUrl:e="",onCancel:t,onSuccess:r,onError:i=()=>{},mode:s="install",handleText:n={}}){const{api:o}=ln(),{api:a,session:d}=tc(),[h,u]=q.useState(!1),[f,j]=q.useState(""),{t:m,locale:E}=wt(),S={dist:{}},{encryptKey:C}=hl(),[_,N]=q.useState(e),[D,c]=q.useState(e?1:0),[w,R]=q.useState(S),[B,M]=q.useState(!1),[re,Z]=q.useState(""),[z]=ri("instant-blocklet-install",!1),[W,H]=q.useState({}),A=s==="component",X=A?!0:!e,{addUrlRecord:$}=bs(),he=q.useMemo(()=>(d.user?.connectedAccounts||[]).some(ye=>ye.provider===Bt.LOGIN_PROVIDER.WALLET),[d.user]),Oe=async()=>{R(S),j(null),u(!0);let te=_.trim();!te.startsWith("https://")&&!te.startsWith("http://")&&!te.startsWith("file://")&&(te=`file://${te}`);try{const Ne=decodeURIComponent(te);try{new URL(Ne)}catch{throw new Error("Invalid URL")}const{meta:ye,inStore:Be,registryUrl:jt}=await o.getBlockletMetaFromUrl({input:{url:Ne}});R(ye),H({inStore:Be,registryUrl:jt,inputUrl:te}),$(te)}catch(Ne){console.error(Ne);const ye=`Blocklet Install failed: ${Br(Ne)}`;j(ye),i(Ne)}finally{u(!1)}},K=()=>{if(A){r({meta:w,...W}),t();return}if(z){u(!0),M(!0);return}const te=Zt(window?.env?.apiPrefix??"/","/launch-blocklet/install");window.location.href=Yn(te,{blocklet_meta_url:decodeURIComponent(_.trim()),from:"url"})},we=()=>{u(!1),M(!1),r({meta:w,...W}),t()},de=()=>{u(!1),M(!1)};q.useEffect(()=>{e&&Oe()},[e]);const Le=q.useMemo(()=>({title:w.title,wt:fl(w),blockletMetaUrl:decodeURIComponent(_.trim())}),[w,_]),ve=q.useCallback(async()=>{if(he||z){Z("");return}const te=new URL(window.location.href);te.pathname=Zt(window?.env?.apiPrefix??"/","/api/did/launch-free-blocklet-by-session/token"),te.searchParams.set("_ek_",C),Object.keys(Le).forEach(ye=>{te.searchParams.set(ye,Le[ye])});const{data:Ne}=await a.get(te.href);Ne.url?Z(Ne.url):Z("")},[he,Le,a,C,z]);q.useEffect(()=>{ve()},[ve]);const _e=q.useMemo(()=>he&&re?{...Le,nw:re,skipMigrateAccount:!0}:Le,[Le,re,he]),Pe=[{name:m("common.name"),value:$t.getDisplayName({meta:w},!0)},{name:m("common.version"),value:w.version},{name:m("common.did"),value:w.did?l.jsx(nc,{did:w.did}):null},{name:m("common.author"),value:w.owner?l.jsx(ys,{owner:w.owner,locale:E}):hu.formatPerson(w.author)},{name:m("blocklet.dist.downloadLink"),value:w.dist.tarball}],He=()=>h?l.jsx("div",{style:{height:200,width:"100%",display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column"},children:l.jsx(Tt,{})}):w.did?l.jsx("div",{style:{paddingLeft:"10%"},children:Pe.map(te=>te.name===m("common.did")?l.jsx(Pi,{valueComponent:"div",nameWidth:120,name:te.name,nameFormatter:()=>m("common.did"),children:te.value},te.name):l.jsx(Pi,{valueComponent:"div",nameWidth:120,name:te.name,children:te.value},te.name))}):null,et=Xl(async()=>{let te=w.title;d.user&&(te=`${d.user.fullName}'s ${w.title}`);try{we(),await o.launchBlockletWithoutWallet({input:{title:te,blockletMetaUrl:decodeURIComponent(_.trim()),type:"store",storeUrl:W.registryUrl,onlyRequired:!0}})}catch(Ne){console.error("launchBlockletWithoutWallet error:",Ne),Gn.error(Br(Ne),{autoHideDuration:3e3})}}),ht=[{label:m("blocklet.fromUrl.step0"),body:l.jsx(je,{component:"div",children:l.jsx(xs,{style:{marginBottom:32},value:_,helperText:m("blocklet.fromUrl.description"),onValueChange:te=>{j(null),N(te)},children:l.jsx(Vn,{label:m("blocklet.fromUrl.label"),autoComplete:"off",variant:"outlined",name:"url","data-cy":"blocklet-url-input",fullWidth:!0,autoFocus:!0,margin:"dense",value:_,onChange:te=>{j(null),N(te.target.value)},disabled:h,onKeyPress:te=>{te.key==="Enter"&&(te.preventDefault(),Oe(),c(1))}})})}),cancel:m("common.cancel"),confirm:m("common.next"),onCancel:t,onConfirm:()=>{Oe(),c(1)}},{label:m("blocklet.fromUrl.step1"),body:He(),cancel:m(X?"common.pre":"common.cancel"),confirm:n?.confirm||m("blocklet.fromUrl.confirm"),onCancel:()=>{X?c(te=>te-1):t()},onConfirm:()=>{K()}}],Ze=ht[D];return l.jsxs(l.Fragment,{children:[l.jsxs(ni,{title:n?.title||m("blocklet.fromUrl.title"),fullWidth:!0,maxWidth:"md",onClose:()=>Ze.onCancel(),showCloseButton:D===0,disableEscapeKeyDown:!0,open:!0,actions:l.jsxs(l.Fragment,{children:[Ze.cancel&&l.jsx(yt,{onClick:te=>{te.stopPropagation(),j(null),Ze.onCancel()},color:"inherit",children:Ze.cancel||m("common.cancel")}),l.jsxs(yt,{onClick:te=>{te.stopPropagation(),Ze.onConfirm()},color:"primary","data-cy":"install-blocklet-next-step",disabled:h||!_||f,variant:"contained",autoFocus:!0,style:{marginLeft:8},children:[h&&D===0&&l.jsx(Tt,{size:16}),Ze.confirm]})]}),children:[X&&l.jsx(wa,{alternativeLabel:!0,activeStep:D,children:ht.map(({label:te})=>l.jsx(Sa,{children:l.jsx(Ea,{children:te})},te))}),l.jsx(ka,{component:"div",style:{marginTop:24},children:Ze.body}),!!f&&l.jsx(Mo,{severity:"error",style:{width:"100%",marginTop:8},children:f})]}),w&&B&&l.jsx(Jo,{popup:!0,open:!0,forceConnected:!1,className:"launch-from-url-auth",action:!he&&!z?"bind-wallet":"launch-free-blocklet-by-session",checkFn:a.get,checkTimeout:5*60*1e3,onSuccess:we,extraParams:_e,messages:{title:m("setup.keyPair.title"),scan:m("setup.keyPair.scan"),confirm:m("setup.keyPair.confirm"),success:m("setup.keyPair.success")},onClose:de,customItems:z?[]:[l.jsx(ws,{onClick:et})]})]})}Ss.propTypes={defaultUrl:F.string,onCancel:F.func.isRequired,onSuccess:F.func.isRequired,onError:F.func,mode:F.oneOf(["install","component"]),handleText:F.object};const pu={meta:F.object.isRequired,onCancel:F.func.isRequired};function Es({action:e,onSelect:t,onNext:r}){const{t:i}=wt(),s=[{action:"purchase",title:i("store.purchase.purchase.title"),description:i("store.purchase.purchase.description")},{action:"verify",title:i("store.purchase.verify.title"),description:i("store.purchase.verify.description")}];return l.jsxs(l.Fragment,{children:[l.jsx(Ta,{children:s.map(n=>l.jsxs(Ao,{button:!0,selected:e===n.action,onClick:()=>t(n.action),children:[l.jsx(ja,{sx:{minWidth:48},children:n.action==="purchase"?l.jsx(Oa,{style:{color:e==="purchase"?Ti.primary.main:"#AAA",fontSize:32}}):l.jsx(Ca,{style:{color:e==="verify"?Ti.primary.main:"#AAA",fontSize:32}})}),l.jsx(Do,{primary:n.title,secondary:n.description})]},n.action))}),r&&l.jsx(yt,{fullWidth:!0,disabled:!e,variant:"contained",color:"primary",style:{marginTop:16},onClick:r,children:i("common.next")})]})}Es.propTypes={action:F.oneOf(["both","purchase","verify"]).isRequired,onSelect:F.func.isRequired,onNext:F.func.isRequired};function ks({meta:e,onCancel:t,mode:r,handlePaySuccess:i=()=>{}}){const{t:s,locale:n}=wt(),{info:o}=ln(),a=pl(o),[d,h]=q.useState(null),u=new URL(e?.registryUrl).origin,f=$t.getDisplayName({meta:e}),j=async(E,S)=>{const C=({downloadTokenList:D})=>{i({downloadTokenList:D})},_=D=>{Gn.error(D),t(D)};function N(D){return gl(()=>Li.get(D).then(async({data:c})=>{const w=c?.downloadTokenList;if(c.status==="succeed"){if(w&&w.length)await C({downloadTokenList:w});else return await _(s("blocklet.component.missDownloadTokenTip")),!0;return!0}return c.status==="error"?(console.error("vc error: ",c),await _(c?.error),!0):!1}),{interval:1e3})}if(r==="purchase"&&d){const{statusUrl:D}=ml(d);await N(D)}else await C({downloadTokenList:E.downloadTokenList&&S(E.downloadTokenList)})};if(q.useEffect(()=>{if(r==="purchase"){const E=new URL(u);E.pathname="/api/did/verify-purchase-blocklet/token",E.searchParams.set("serverDid",o.did),E.searchParams.set("blockletDid",e?.did);try{Li.get(E.href).then(({data:S})=>{const C=`${S.url}`;h(C)})}catch(S){console.error("get next workflow url error: ",S)}}return()=>{h(null)}},[r]),r==="purchase"&&!d)return"";const m={verify:{action:"verify-purchase-blocklet",checkFn:Ri.create({baseURL:u}).get,extraParams:{serverDid:o.did,blockletDid:e?.did},messages:{title:s("store.purchase.verify.auth.title",{name:f}),scan:s("store.purchase.verify.auth.scan"),confirm:s("store.purchase.verify.auth.confirm"),success:s("store.purchase.verify.auth.success")}},purchase:{action:"acquire-asset",checkFn:Ri.create({baseURL:Zt(u,"/store")}).get,extraParams:{factory:e.nftFactory,nw:d},messages:{title:s("store.purchase.auth.title",{name:f}),scan:s("store.purchase.auth.scan"),confirm:s("store.purchase.auth.confirm"),success:l.jsxs(l.Fragment,{children:[l.jsx("p",{children:s("store.purchase.auth.success")}),l.jsx("p",{children:s("blocklet.component.purchaseComponentSecondCheckTip")})]})}}};return l.jsx(Jo,{open:!0,locale:n,popup:!1,saveConnect:!1,className:"connect",baseUrl:u,onSuccess:j,cancelWhenScanned:t,onClose:t,checkTimeout:60*5e3,webWalletUrl:a,disableClose:!0,showDownload:!1,...m[r]})}ks.propTypes={...pu,handlePaySuccess:F.func,mode:F.oneOf(["verify","purchase"]).isRequired};function Ts({ref:e=null,mode:t,...r}){const[i,s]=q.useState(t!=="both"?t:"verify"),[n,o]=q.useState(t!=="both"?2:1),a=h=>{h!==i&&s(h)},d=()=>{i&&n!==2&&o(2)};return q.useImperativeHandle(e,()=>({onNext:d,getCurrentStep:()=>n})),n===1?l.jsx("div",{style:{maxWidth:520},children:l.jsx(Es,{action:i,onNext:null,onSelect:a})}):l.jsx(ks,{...r,mode:i})}Ts.propTypes={mode:F.oneOf(["both","verify","purchase"]).isRequired,ref:F.any};function mu({...e}){return l.jsx(yt,{className:"bottom-button",variant:"contained",color:"primary",...e})}function js({blocklet:e=null,onStartNow:t=()=>{},children:r=null,disabled:i=!1}){const{t:s}=wt(),n=is();return!e||vl(e.meta)?l.jsx(gu,{children:r}):l.jsxs(vu,{isMobile:n,children:[l.jsx(mu,{className:"start-now",variant:"contained",color:"primary",disabled:i,onClick:()=>t(),children:s("setup.startNow")}),l.jsx(oe,{sx:{display:"flex",alignItems:"center"},children:r})]})}js.propTypes={blocklet:F.object,onStartNow:F.func,children:F.any,disabled:F.bool};const gu=it(oe)`
|
|
220
|
+
`),B=c.string().trim().min(1).custom(V=>{if(N(V)>m.MAX_TITLE_LENGTH)throw new Error(`title length should not exceed ${m.MAX_TITLE_LENGTH} (see: https://www.npmjs.com/package/cjk-length)`);return V}).meta({className:"TTitle"});ie.titleSchema=B;const M=c.string().trim().min(3).max(160).meta({className:"TDescription"});ie.descriptionSchema=M;const re=c.string().trim().min(3).max(20).messages({"*":"Title length must be between 3 and 20 characters"}).meta({className:"TInstallBlockletTitle"});ie.installBlockletTitleSchema=re;const Z=c.string().trim().min(3).max(80).messages({"*":"Description length must be between 3 and 80 characters"}).meta({className:"TInstallBlockletDescription"});ie.installBlockletDescriptionSchema=Z;const z=c.string().uri({scheme:["http","https"],allowRelative:!0}).allow("").custom((V,ae)=>V.includes(u.WELLKNOWN_BLOCKLET_LOGO_PATH)?ae.message(`logo url should not include ${u.WELLKNOWN_BLOCKLET_LOGO_PATH}`):V).meta({className:"TLogo"});ie.logoSchema=z;const W=c.string().trim().min(1),H=W.meta({className:"TMountPoint"}).custom((V,ae)=>(0,_.isValidUrlPath)(V)?V:ae.message(`mountPoint cannot contain such characters space $*+~()'"!:@\\`));ie.mountPointSchema=H;const A=W.meta({className:"TUpdateMountPoint"}).custom(V=>(0,_.default)(V));ie.updateMountPointSchema=A;const X=c.string().custom(V=>((0,C.validateName)(V),V)).meta({className:"TBlockletName"});ie.blockletNameSchema=X;const $=[],he=c.string().trim().min(1).max(50).required().custom((V,ae)=>V.startsWith("BLOCKLET")&&!$.includes(V)?ae.message("Env name can not start with BLOCKLET_"):V.startsWith("COMPONENT")?ae.message("Env name can not start with COMPONENT_"):V.startsWith("ABTNODE")?ae.message("Env name can not start with ABTNODE_"):/[^\w]/.test(V)?ae.message('Env name can include only numbers or letters or "_"'):V).meta({className:"TEnvironmentName",unknownType:"any"});ie.environmentNameSchema=he;const Oe=c.object({name:he.required(),description:c.string().trim().required(),default:c.string().optional().allow("").default(""),required:c.boolean().default(!1),secure:c.boolean().default(!1),validation:c.string().optional(),shared:c.boolean().default(V=>V.secure?!1:void 0)}).custom((V,ae)=>V.secure&&V.default?ae.message(`Cannot declare default value for secure env ${V.name}`):V).meta({className:"TEnvironment",unknownType:"any"});ie.environmentSchema=Oe;const K=c.object({dev:c.string().trim().min(1),e2eDev:c.string().trim().min(1),preFlight:c.string().trim().min(1),preInstall:c.string().trim().min(1),postInstall:c.string().trim().min(1),preStart:c.string().trim().min(1),postStart:c.string().trim().min(1),preStop:c.string().trim().min(1),preUninstall:c.string().trim().min(1),preConfig:c.string().trim().min(1)}).rename("pre-flight","preFlight").rename("pre-install","preInstall").rename("post-install","postInstall").rename("pre-start","preStart").rename("post-start","postStart").rename("pre-stop","preStop").rename("pre-uninstall","preUninstall").rename("pre-config","preConfig").optional().meta({className:"TScripts",unknownType:"any"});ie.scriptsSchema=K;const we=c.object({name:c.string().required().trim(),config:c.object().optional().default({})}).unknown(!0).meta({className:"TService",unknownType:"any"});ie.serviceSchema=we;const de=c.object({type:c.string().trim(!0).min(1).required(),path:c.string().required(),meta:c.object({vcType:c.string(),payable:c.boolean(),params:c.array().items({name:c.string().required().trim(),description:c.string().required().trim()})})}).meta({className:"TEndpoint",unknownType:"any"});ie.endpointSchema=de;const Le=c.string().trim().custom((V,ae)=>{const me=V.split("/").filter(Boolean);return me.length===0?ae.message("cacheable path must be a valid pathname that is not /"):`/${me.join("/")}`}).meta({className:"TPathPrefix",unknownType:"any"});ie.cacheableSchema=Le;const ve=c.object({type:c.string().lowercase().valid(...m.BLOCKLET_INTERFACE_TYPES).required(),name:c.string().trim().required(),path:c.string().trim().default("/"),prefix:c.string().trim().min(1).default(m.BLOCKLET_DYNAMIC_PATH_PREFIX),containerPort:c.number().port().optional(),hostIP:c.string().trim().ip({version:["ipv4","ipv6"]}).optional(),protocol:c.string().lowercase().valid(...m.BLOCKLET_INTERFACE_PROTOCOLS).default("http"),port:c.alternatives().try(c.string().uppercase().default(m.BLOCKLET_DEFAULT_PORT_NAME),c.object({internal:c.string().uppercase().required(),external:c.number().port().required()})).default(m.BLOCKLET_DEFAULT_PORT_NAME),cacheable:c.array().items(Le).unique(),services:c.array().items(we).unique("name"),endpoints:c.array().items(de).unique("type"),pageGroups:c.array().items(c.string().min(1).max(255).trim()).unique(),proxyBehavior:c.string().valid("service","direct").default("service").optional()}).meta({className:"TInterface",unknownType:"any"});ie.interfaceSchema=ve;const _e=c.alternatives().try(c.string().required(),c.object({url:c.string().uri({scheme:["http","https","file"]}).required(),name:X.required(),version:c.alternatives().try(c.string().valid("latest"),c.semverRange().valid())}),c.object({store:c.string().uri({scheme:["http","https"]}).required(),name:X.required(),version:c.alternatives().try(c.string().valid("latest"),c.semverRange().valid()).default("latest")})),Pe=c.object({platform:c.string().valid(...m.BLOCKLET_PLATFORMS).optional(),interpreter:c.string().valid("binary","node","blocklet","bun").default("node"),source:_e,args:c.array().items(c.string()).optional().default([])}).meta({className:"TEngine",unknownType:"any"});ie.engineSchema=Pe;const He=c.object({name:c.string().min(1).required(),email:c.string().email({tlds:!1}).optional(),url:c.string().uri().optional()}).meta({className:"TPerson",unknownType:"any"});ie.personSchema=He;const et=c.object({tarball:c.alternatives().try(c.string().uri(),c.string()).required(),integrity:c.string().required(),size:c.number().optional()}).meta({className:"TDist",unknownType:"any"});ie.distSchema=et;const ht=c.object({downloads:c.number().integer().greater(-1),star:c.number().default(0),purchases:c.number().default(0)}).meta({className:"TStats",unknownType:"any"});ie.statsSchema=ht;const te={source:c.alternatives().try(c.object({url:c.alternatives().try(c.string().uri(),c.array().items(c.string().uri()).min(1)).required(),version:c.alternatives().try(c.string().valid("latest"),c.semverRange().valid())}),c.object({store:c.string().uri({scheme:["http","https"]}),name:X.required(),version:c.alternatives().try(c.string().valid("latest"),c.semverRange().valid()).default("latest")})).required(),required:c.boolean(),title:B,description:M,mountPoint:H,name:X},Ne=(V,ae)=>c.object(V).custom((me,Ce)=>!ae&&me.source&&me.source.name&&!me.source.store?Ce.message(`missing 'store' in source of component ${me.name}`):me),ye=Ne(te).meta({className:"TComponent",unknownType:"any"});ie.componentSchema=ye;const Be=Ne(te,!0),jt=({checkStore:V}={})=>{const ae=[ye,Be];return c.array().items(V?ae[0]:ae[1]).optional().default([])},Ot=c.object({type:c.string().required(),name:c.string().required(),signer:c.string().required(),pk:c.string().required(),created:c.string().isoDate().required(),sig:c.string().required(),excludes:c.array().items(c.string()).optional(),appended:c.array().items(c.string()).optional(),delegatee:c.string(),delegateePk:c.string(),delegation:c.string()}).meta({className:"TSignature",unknownType:"any"});ie.signatureSchema=Ot;const Me=["en","zh","fr","ru","ar","es","de","pt","ja","hi"],Ct={id:c.string().custom(R),title:c.alternatives().try(c.string().min(1).max(m.MAX_TITLE_LENGTH),c.object().min(1).pattern(c.string().valid(...Me),c.string().min(1).max(m.MAX_TITLE_LENGTH))).required(),description:c.alternatives().try(c.string().min(1).max(m.MAX_DESCRIPTION_LENGTH),c.object().min(1).pattern(c.string().valid(...Me),c.string().min(1).max(m.MAX_DESCRIPTION_LENGTH))),link:c.alternatives().try(c.string().custom(w),c.object().min(1).pattern(c.string().valid(...Me),c.string().custom(w))),component:c.string().min(1),section:c.array().items(c.string().min(1)).single(),role:c.array().items(c.string().min(1)).single(),icon:c.string().min(1),visible:c.boolean()},Et=c.object({...Ct,items:c.array().items(c.object({...Ct}).rename("child","component"))}).rename("child","component").meta({className:"TNavigationItem",unknownType:"any"});ie.navigationItemSchema=Et;const _t=c.array().items(Et).unique((V,ae)=>V.id&&ae.id?V.id===ae.id:!1).meta({className:"TNavigation",unknownType:"any"});ie.navigationSchema=_t;const Ye=c.object({background:c.alternatives().try(c.string().min(1),c.object({header:c.string().min(1),footer:c.string().min(1),default:c.string().min(1)}).min(1))}).meta({className:"TTheme",unknownType:"any"});ie.themeSchema=Ye;const It=c.object({whoCanAccess:c.string().valid("owner","invited","all"),profileFields:c.array().items(c.string().valid("fullName","email","avatar","phone")).unique(),ignoreUrls:c.array().items(c.string().min(1)),allowSwitchProfile:c.boolean(),blockUnauthenticated:c.boolean(),blockUnauthorized:c.boolean()}).options({stripUnknown:!0}).meta({className:"TAuthConfig",unknownType:"any"});ie.authConfigSchema=It;const Nt=c.object({type:c.string().trim().min(1).required(),description:c.string().trim().min(1)}),at=c.object({did:c.DID().trim().required(),type:c.string().trim().min(1).required(),public:c.boolean()}).meta({className:"TResourceBundle",unknownType:"any"});ie.resourceBundleSchema=at;const qe=c.array().items(c.object({type:c.string().trim().min(1).max(128).pattern(/^(?!blocklet\.)[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/).message('Event type must be in format of "[noun.]verb" like "post.published" or "post.comment.published", and prefix "blocklet." is reserved').required(),description:c.string().trim().min(1).max(256).required()})).unique("type").meta({className:"TEvent",unknownType:"any"});ie.eventsSchema=qe;const tt={did:c.DID().trim().required(),version:c.semver().valid().required(),name:c.string().optional(),description:M.required(),group:c.string().valid(...m.BLOCKLET_GROUPS),main:c.string().trim(),title:B.optional().allow(""),logo:c.string().trim().optional(),specVersion:c.semver().valid().gte("1.0.0").optional(),author:He.optional(),contributors:c.array().items(He).optional(),maintainers:c.array().items(He).optional(),community:c.string().uri().optional().allow("").default(""),documentation:c.string().uri().optional().allow("").default(""),homepage:c.string().uri().optional().allow("").default(""),license:c.string().optional().allow("").default(""),support:c.alternatives().try(c.string().uri(),c.string().email({tlds:!1})).optional(),nftFactory:c.DID().optional().allow("").default(""),payment:c.object({price:c.array().max(1).items(c.object({value:c.number().greater(0).required(),address:c.DID().required()})).default([]),share:c.array().max(4).items(c.object({name:c.string().required(),address:c.DID().required(),value:c.number().greater(0).max(1).required()})).default([]).custom(V=>{if(V.length===0)return V;const ae=V.reduce((me,Ce)=>me+Ce.value,0);if(ae!==1)throw new Error(`Invalid blocklet payment share config: total share must be 1, got ${ae}`);return V},"invalid blocklet share"),componentPrice:c.array().items(c.object({parentPriceRange:c.array().items(c.number()).custom((V,ae)=>V.length!==2?ae.message("length of range should be 2"):V[0]<0?ae.message("the first value should not less than 0 in range"):V[1]<=V[0]?ae.message("the second value should greater than the first value in range"):V),type:c.string().valid("fixed","percentage").required(),value:c.number().greater(0).required()})).single()}).default({price:[],share:[]}),keywords:c.alternatives().try(c.string().trim().min(1),c.array().items(c.string().min(1))).optional(),tags:c.alternatives().try(c.string().trim().min(1),c.array().items(c.string().min(1))).optional(),gitHash:c.string().optional().allow(""),repository:c.alternatives().try(c.string().min(1),c.object({type:c.string().valid("git","https","svn").required(),url:c.string().uri().required(),directory:c.string()})).optional(),timeout:c.object({start:c.number().min(10).max(600),script:c.number().min(1).max(1800)}).default({start:60}),requirements:c.object({abtnode:c.semverRange().valid(),server:c.semverRange().valid(),os:c.alternatives().try(c.string().valid("*",...m.BLOCKLET_PLATFORMS),c.array().items(c.string().valid(...m.BLOCKLET_PLATFORMS)).min(1)),cpu:c.alternatives().try(c.string().valid("*",...m.BLOCKLET_ARCHITECTURES),c.array().items(c.string().valid(...m.BLOCKLET_ARCHITECTURES)).min(1)),fuels:c.array().items(c.object({endpoint:c.string().trim().required(),address:c.string().trim(),value:c.string().trim().required(),reason:c.string().trim().required()})),nodejs:c.semverRange().valid()}).default({server:m.BLOCKLET_LATEST_REQUIREMENT_SERVER,os:"*",cpu:"*",nodejs:"*"}),interfaces:c.array().items(ve).unique("name").custom((V,ae)=>{if(V.filter(ee=>ee.type===m.BLOCKLET_INTERFACE_TYPE_WEB).length>1)return ae.message(`Only one ${m.BLOCKLET_INTERFACE_TYPE_WEB} interface can be declared`);const Ce=V.filter(ee=>ee.type===m.BLOCKLET_INTERFACE_TYPE_WELLKNOWN);for(const ee of Ce)if(!ee.prefix.startsWith(D))return ae.message(`Wellknown path prefix must start with: ${D}`);return V}).default([]),environments:c.array().items(Oe).default([]).optional().custom((V,ae)=>{if(V&&V.length){const me=V.filter((Ce,ee)=>V.findIndex(O=>O.name===Ce.name)!==ee);if(me.length)return ae.message(`find duplicate environment names ${me.map(Ce=>Ce.name).join(", ")}`)}return V}),scripts:K,capabilities:c.object({clusterMode:c.boolean(),didSpace:c.string().valid(...Object.values(m.BLOCKLET_APP_SPACE_REQUIREMENT)).optional(),navigation:c.boolean().default(!0),serverless:c.boolean().optional(),component:c.boolean(),sitemap:c.boolean().optional(),mcp:c.boolean().optional()}).default({}),files:c.array().items(c.string().trim()).optional(),resource:c.object({exportApi:c.string().trim(),bundles:c.array().items(at),types:c.array().items(Nt).max(10)}),engine:c.alternatives().try(Pe,c.array().items(Pe)).optional(),screenshots:c.array().items(c.string().min(1)).optional().default([]),videos:c.array().items(c.string().pattern(/^https:\/\/(www\.)?(youtube\.com|youtu\.be|vimeo\.com)\/[\w\-/?&=]+/).message("Each video URL must be a valid YouTube or Vimeo link")).max(3).optional(),logoUrl:c.string().optional().allow(""),dist:et.optional(),stats:ht.optional(),htmlAst:c.any().optional(),path:c.string().optional(),signatures:c.array().items(Ot).optional(),lastPublishedAt:c.string().isoDate().optional().allow(null),components:jt(),navigation:_t,theme:Ye,copyright:c.object({owner:c.string().min(1),year:c.alternatives().try(c.string(),c.number())}),bundleName:c.string(),bundleDid:c.DID().trim(),storeId:c.string(),events:qe.optional()},ot=c.object(tt).options({stripUnknown:!0,noDefaults:!1}).meta({className:"TBlockletMeta",unknownType:"any"});ie.blockletMetaSchema=ot;const mt=(V,{ensureFiles:ae=!1,ensureDist:me=!1,ensureComponentStore:Ce=!0,ensureName:ee=!1,skipValidateDidName:O=!1,...Ie}={})=>((!V||!s.default.existsSync(V))&&(ae=!1),c.object({...tt,owner:c.object({avatar:c.string().optional(),did:c.DID().trim().required(),fullName:c.string().trim().required(),email:c.string().optional().allow(null).empty("").default("")}).optional(),logo:ae?c.file().trim().exists({baseDir:V}).optional():c.string().trim().optional(),files:c.array().items(ae?c.file().exists({baseDir:V,canSkip:(Re,Fe)=>[m.BLOCKLET_ENTRY_FILE,m.BLOCKLET_BUNDLE_FILE].includes(Fe)||(0,a.default)(Fe)}):c.string().trim()).optional(),dist:me?et.required():et.optional(),components:jt({checkStore:Ce}),name:ee?c.string().optional():c.string().required(),egress:c.boolean().optional().default(!0),docker:j.dockerSchema}).options({stripUnknown:!0,noDefaults:!1,...Ie}).rename("children","components").custom((Re,Fe)=>{const{did:p,name:x,docker:k}=Re;if(k){const{image:U,dockerfile:ne,network:le}=k;if(!U&&!ne)return Fe.message("Image or dockerfile must be set");if(U&&ne)return Fe.message("Image and dockerfile cannot be set at the same time");if(le)return Fe.message("ExportPorts and network cannot be set at the same time");ne&&(Re.files||(Re.files=[]),Re.files.push(ne))}let L;if((0,f.isValid)(p))try{return(0,C.validateNewDid)(p),Re}catch(U){L=U}if(x){(0,C.validateName)(x,{checkDid:!O});const U=(0,E.default)(x);return U!==p?Fe.message(`The did of name "${x}" should be "${U}"`):Re}return L?Fe.message(L.message):Re}));return ie.createBlockletSchema=mt,ie.default={blockletNameSchema:X,componentSchema:ye,endpointSchema:de,serviceSchema:we,createBlockletSchema:mt,interfaceSchema:ve,environmentSchema:Oe,environmentNameSchema:he,scriptsSchema:K,personSchema:He,distSchema:et,titleSchema:B,descriptionSchema:M,logoSchema:z,navigationSchema:_t,themeSchema:Ye,mountPointSchema:H,updateMountPointSchema:A,authConfigSchema:It,resourceBundleSchema:at,installBlockletTitleSchema:re,installBlockletDescriptionSchema:Z,eventsSchema:qe,Joi:c},ie}var pt={},io;function cu(){if(io)return pt;io=1;var e=pt&&pt.__importDefault||function(h){return h&&h.__esModule?h:{default:h}};Object.defineProperty(pt,"__esModule",{value:!0}),pt.setService=pt.findService=pt.getDefaultServiceConfig=pt.getServiceConfig=void 0;const t=e(ec),r=vs(),i={},s=h=>{i[h.name]={validate:h.schema.validate.bind(h.schema),defaultConfig:h.default}};pt.setService=s,s({name:"auth",schema:r.authConfigSchema,default:{}});const n=h=>{if(!h)throw new Error("service name should not be empty");const u=i[h];if(!u)throw new Error(`service ${h} does not exist`);return u},o=(h,u,{validate:f}={})=>{const j=n(h),m=(0,t.default)(u||{}),{value:E,error:S}=j.validate(m);if(f&&S)throw new Error(`Invalid blocklet service config: ${S.details.map(C=>C.message).join(", ")}`);return E};pt.getServiceConfig=o;const a=h=>{const{defaultConfig:u}=n(h);return u};pt.getDefaultServiceConfig=a;const d=(h,u)=>{const f=[u];return(h||[]).find(j=>f.includes(j.name))};return pt.findService=d,pt.default={getServiceConfig:o,getDefaultServiceConfig:a,findService:d,setService:s},pt}var oo;function uu(){if(oo)return Vt;oo=1,Object.defineProperty(Vt,"__esModule",{value:!0}),Vt.fixAndValidateService=Vt.validateMeta=void 0;const e=vs(),t=cu(),r=s=>(!s.interfaces||!s.interfaces.length||s.interfaces.forEach(n=>{n.services&&n.services.length&&n.services.forEach(o=>{o.config=(0,t.getServiceConfig)(o.name,o.config,{validate:!0})})}),s);Vt.fixAndValidateService=r;const i=(s,{ensureFiles:n=!1,ensureDist:o=!1,ensureComponentStore:a=!0,ensureName:d=!1,skipValidateDidName:h=!1,schemaOptions:u={}}={})=>{const f=(0,e.createBlockletSchema)(null,{ensureFiles:n,ensureDist:o,ensureComponentStore:a,ensureName:d,skipValidateDidName:h,...u}),{value:j,error:m}=f.validate(s);if(m)throw new Error(`Invalid blocklet meta: ${m.details.map(E=>E.message).join(", ")}`);return j};return Vt.validateMeta=i,Vt.default=i,Vt}var so;function du(){return so||(so=1,function(e){var t=kt&&kt.__createBinding||(Object.create?function(w,R,B,M){M===void 0&&(M=B);var re=Object.getOwnPropertyDescriptor(R,B);(!re||("get"in re?!R.__esModule:re.writable||re.configurable))&&(re={enumerable:!0,get:function(){return R[B]}}),Object.defineProperty(w,M,re)}:function(w,R,B,M){M===void 0&&(M=B),w[M]=R[B]}),r=kt&&kt.__setModuleDefault||(Object.create?function(w,R){Object.defineProperty(w,"default",{enumerable:!0,value:R})}:function(w,R){w.default=R}),i=kt&&kt.__importStar||function(){var w=function(R){return w=Object.getOwnPropertyNames||function(B){var M=[];for(var re in B)Object.prototype.hasOwnProperty.call(B,re)&&(M[M.length]=re);return M},w(R)};return function(R){if(R&&R.__esModule)return R;var B={};if(R!=null)for(var M=w(R),re=0;re<M.length;re++)M[re]!=="default"&&t(B,R,M[re]);return r(B,R),B}}(),s=kt&&kt.__importDefault||function(w){return w&&w.__esModule?w:{default:w}};Object.defineProperty(e,"__esModule",{value:!0}),e.fixService=e.fixInterfaces=e.parsePerson=e.formatPerson=e.fixName=e.fixTags=e.fixPerson=e.fixKeywords=e.fixFiles=e.fixRepository=e.fixRequired=void 0;const n=s(cl),o=i(Kc()),a=Yo(),d=uu();Object.defineProperty(e,"fixService",{enumerable:!0,get:function(){return d.fixAndValidateService}});const h=gs(),u=(w,R)=>{w.description||(w.description=`Blocklet from ${R}`),w.version||(w.version=a.BLOCKLET_DEFAULT_VERSION)};e.fixRequired=u;const f=w=>{if(w.repository&&(typeof w.repository=="string"&&(w.repository={type:"git",url:w.repository}),w.repository.url)){const R=o.fromUrl(w.repository.url);R&&(w.repository.url=R.getDefaultRepresentation()==="shortcut"?R.https():R.toString())}};e.fixRepository=f;const j=w=>{Array.isArray(w.files)?w.files&&(w.files=w.files.filter(R=>!(!R||typeof R!="string"))):delete w.files};e.fixFiles=j;const m=w=>{typeof w.keywords=="string"&&(w.keywords=w.keywords.split(/,\s+/)),w.keywords&&!Array.isArray(w.keywords)?delete w.keywords:w.keywords&&(w.keywords=w.keywords.filter(R=>!(typeof R!="string"||!R)))};e.fixKeywords=m;const E=w=>{typeof w.tags=="string"&&(w.tags=w.tags.split(/,\s+/)),w.tags&&!Array.isArray(w.tags)?delete w.tags:w.tags&&(w.tags=w.tags.filter(R=>!(typeof R!="string"||!R)))};e.fixTags=E;const S=(w,R)=>(w.author&&(w.author=R(w.author)),["maintainers","contributors"].forEach(B=>{Array.isArray(w[B])&&(w[B]=w[B].map(R))}),w),C=w=>{if(!w)return"";if(typeof w=="string")return w;const R=w.name||"",B=w.url||w.web,M=B?` (${B})`:"",re=w.email||w.mail,Z=re?` <${re}>`:"";return R+Z+M};e.formatPerson=C;const _=w=>{if(typeof w!="string")return w;const R=w.match(/^([^(<]+)/),B=w.match(/\(([^)]+)\)/),M=w.match(/<([^>]+)>/),re={};return R&&R[0].trim()&&(re.name=R[0].trim()),M&&([,re.email]=M),B&&([,re.url]=B),re};e.parsePerson=_;const N=w=>(S(w,C),S(w,_),w);e.fixPerson=N;const D=(w,R=!0)=>{if(Array.isArray(w.interfaces)||(w.interfaces=[]),w.interfaces.length)return w.interfaces.forEach(Z=>{Z.type===a.BLOCKLET_INTERFACE_TYPE_WEB&&(Z.protocol="http")}),w;const M=(0,n.default)(w,"capabilities.dynamicPathPrefix",!0)?a.BLOCKLET_DYNAMIC_PATH_PREFIX:"/",re=({type:Z="web",name:z,path:W="/",protocol:H="http",port:A=a.BLOCKLET_DEFAULT_PORT_NAME})=>{w.interfaces.push({type:Z,name:z,path:W,prefix:M,port:A,protocol:H})};return[a.BLOCKLET_INTERFACE_PUBLIC].forEach(Z=>{w[Z]&&re({name:Z,path:w[Z]})}),Array.isArray(w.exposeServices)&&w.exposeServices.forEach(Z=>{re({type:"service",name:Z.protocol,protocol:Z.protocol,port:{internal:`BLOCKLET_${Z.protocol}_PORT`.toUpperCase(),external:Z.port}})}),R&&(delete w.publicUrl,delete w.adminUrl,delete w.configUrl,delete w.docUrl,delete w.exposeServices,w.capabilities&&delete w.capabilities.dynamicPathPrefix),w};e.fixInterfaces=D;const c=w=>{const{did:R}=w;try{(0,h.validateNewDid)(R),w.name=R}catch{}return w};e.fixName=c,e.default={fixRequired:u,fixRepository:f,fixFiles:j,fixKeywords:m,fixPerson:N,fixTags:E,fixName:c,formatPerson:C,parsePerson:_,fixInterfaces:D,fixService:d.fixAndValidateService}}(kt)),kt}var hu=du();function ys({owner:e,locale:t}){return l.jsxs(oe,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.fullName,e.did?l.jsx(Go,{sx:{lineHeight:"initial","&::before":{content:'"("'},"&::after":{content:'")"'}},did:e.did,compact:!0,size:14,locale:t}):null]})}ys.propTypes={owner:F.object.isRequired,locale:F.string.isRequired};const fu="install-blocklet-from-URL",bs=()=>{const[e,t]=ri(fu,"[]",{raw:!0}),r=s=>{const n=s.trim(),o=JSON.parse(e),a=o.findIndex(d=>d===n);a!==0&&(a>0&&o.splice(a,1),o.length>=10&&o.splice(9),o.unshift(n),t(JSON.stringify(o)))},i=s=>{if(!s)return;const n=JSON.parse(e),o=s.trim(),a=n.findIndex(d=>d===o);a>-1&&(n.splice(a,1),t(JSON.stringify(n)))};return{urls:e?JSON.parse(e):[],addUrlRecord:r,removeUrlRecord:i}};function xs({value:e="",onValueChange:t=()=>{},children:r=null,helperText:i=""}){const{urls:s,removeUrlRecord:n}=bs(),o=(a,d)=>{a.preventDefault(),a.stopPropagation(),n(d)};return l.jsxs(oe,{children:[l.jsx(No,{freeSolo:!0,options:s,inputValue:e,onInputChange:(a,d)=>{t(d)},disableClearable:!0,popupIcon:null,renderInput:a=>Ut.cloneElement(r,{...a}),renderOption:(a,d)=>q.createElement(Ao,{...a,key:d,secondaryAction:l.jsx(_o,{edge:"end","aria-label":"delete",onClick:h=>o(h,d),children:l.jsx(ya,{})})},l.jsx(ba,{role:void 0,dense:!0,sx:{paddingLeft:0,paddingRight:30,"&:hover":{backgroundColor:"transparent"}},children:l.jsx(Do,{primary:d,sx:{"& span":{display:"block",width:"100%",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"}}})})),slotProps:{listbox:{sx:{maxHeight:300,overflow:"auto"}}}}),l.jsx(xa,{style:{margin:0},children:i})]})}xs.propTypes={onValueChange:F.func,children:F.node,value:F.string,helperText:F.string};function ws({onClick:e}){const{t}=wt();return l.jsx(ul,{title:t("launchBlocklet.withoutWallet"),icon:l.jsx(bt,{icon:dl,fontSize:"1em"}),onClick:e})}ws.propTypes={onClick:F.func.isRequired};function Ss({defaultUrl:e="",onCancel:t,onSuccess:r,onError:i=()=>{},mode:s="install",handleText:n={}}){const{api:o}=ln(),{api:a,session:d}=tc(),[h,u]=q.useState(!1),[f,j]=q.useState(""),{t:m,locale:E}=wt(),S={dist:{}},{encryptKey:C}=hl(),[_,N]=q.useState(e),[D,c]=q.useState(e?1:0),[w,R]=q.useState(S),[B,M]=q.useState(!1),[re,Z]=q.useState(""),[z]=ri("instant-blocklet-install",!1),[W,H]=q.useState({}),A=s==="component",X=A?!0:!e,{addUrlRecord:$}=bs(),he=q.useMemo(()=>(d.user?.connectedAccounts||[]).some(ye=>ye.provider===Bt.LOGIN_PROVIDER.WALLET),[d.user]),Oe=async()=>{R(S),j(null),u(!0);let te=_.trim();!te.startsWith("https://")&&!te.startsWith("http://")&&!te.startsWith("file://")&&(te=`file://${te}`);try{const Ne=decodeURIComponent(te);try{new URL(Ne)}catch{throw new Error("Invalid URL")}const{meta:ye,inStore:Be,registryUrl:jt}=await o.getBlockletMetaFromUrl({input:{url:Ne}});R(ye),H({inStore:Be,registryUrl:jt,inputUrl:te}),$(te)}catch(Ne){console.error(Ne);const ye=`Blocklet Install failed: ${Br(Ne)}`;j(ye),i(Ne)}finally{u(!1)}},K=()=>{if(A){r({meta:w,...W}),t();return}if(z){u(!0),M(!0);return}const te=Zt(window?.env?.apiPrefix??"/","/launch-blocklet/install");window.location.href=Yn(te,{blocklet_meta_url:decodeURIComponent(_.trim()),from:"url"})},we=()=>{u(!1),M(!1),r({meta:w,...W}),t()},de=()=>{u(!1),M(!1)};q.useEffect(()=>{e&&Oe()},[e]);const Le=q.useMemo(()=>({title:w.title,wt:fl(w),blockletMetaUrl:decodeURIComponent(_.trim())}),[w,_]),ve=q.useCallback(async()=>{if(he||z){Z("");return}const te=new URL(window.location.href);te.pathname=Zt(window?.env?.apiPrefix??"/","/api/did/launch-free-blocklet-by-session/token"),te.searchParams.set("_ek_",C),Object.keys(Le).forEach(ye=>{te.searchParams.set(ye,Le[ye])});const{data:Ne}=await a.get(te.href);Ne.url?Z(Ne.url):Z("")},[he,Le,a,C,z]);q.useEffect(()=>{ve()},[ve]);const _e=q.useMemo(()=>he&&re?{...Le,nw:re,skipMigrateAccount:!0}:Le,[Le,re,he]),Pe=[{name:m("common.name"),value:$t.getDisplayName({meta:w},!0)},{name:m("common.version"),value:w.version},{name:m("common.did"),value:w.did?l.jsx(nc,{did:w.did}):null},{name:m("common.author"),value:w.owner?l.jsx(ys,{owner:w.owner,locale:E}):hu.formatPerson(w.author)},{name:m("blocklet.dist.downloadLink"),value:w.dist.tarball}],He=()=>h?l.jsx("div",{style:{height:200,width:"100%",display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column"},children:l.jsx(Tt,{})}):w.did?l.jsx("div",{style:{paddingLeft:"10%"},children:Pe.map(te=>te.name===m("common.did")?l.jsx(Pi,{valueComponent:"div",nameWidth:120,name:te.name,nameFormatter:()=>m("common.did"),children:te.value},te.name):l.jsx(Pi,{valueComponent:"div",nameWidth:120,name:te.name,children:te.value},te.name))}):null,et=Xl(async()=>{let te=w.title;d.user&&(te=`${d.user.fullName}'s ${w.title}`);try{we(),await o.launchBlockletWithoutWallet({input:{title:te,blockletMetaUrl:decodeURIComponent(_.trim()),type:"store",storeUrl:W.registryUrl,onlyRequired:!0}})}catch(Ne){console.error("launchBlockletWithoutWallet error:",Ne),Gn.error(Br(Ne),{autoHideDuration:3e3})}}),ht=[{label:m("blocklet.fromUrl.step0"),body:l.jsx(je,{component:"div",children:l.jsx(xs,{style:{marginBottom:32},value:_,helperText:m("blocklet.fromUrl.description"),onValueChange:te=>{j(null),N(te)},children:l.jsx(Vn,{label:m("blocklet.fromUrl.label"),autoComplete:"off",variant:"outlined",name:"url","data-cy":"blocklet-url-input",fullWidth:!0,autoFocus:!0,margin:"dense",value:_,onChange:te=>{j(null),N(te.target.value)},disabled:h,onKeyPress:te=>{te.key==="Enter"&&(te.preventDefault(),Oe(),c(1))}})})}),cancel:m("common.cancel"),confirm:m("common.next"),onCancel:t,onConfirm:()=>{Oe(),c(1)}},{label:m("blocklet.fromUrl.step1"),body:He(),cancel:m(X?"common.pre":"common.cancel"),confirm:n?.confirm||m("blocklet.fromUrl.confirm"),onCancel:()=>{X?c(te=>te-1):t()},onConfirm:()=>{K()}}],Ze=ht[D];return l.jsxs(l.Fragment,{children:[l.jsxs(ni,{title:n?.title||m("blocklet.fromUrl.title"),fullWidth:!0,maxWidth:"md",onClose:()=>Ze.onCancel(),showCloseButton:D===0,disableEscapeKeyDown:!0,open:!0,actions:l.jsxs(l.Fragment,{children:[Ze.cancel&&l.jsx(yt,{onClick:te=>{te.stopPropagation(),j(null),Ze.onCancel()},color:"inherit",children:Ze.cancel||m("common.cancel")}),l.jsxs(yt,{onClick:te=>{te.stopPropagation(),Ze.onConfirm()},color:"primary","data-cy":"install-blocklet-next-step",disabled:h||!_||f,variant:"contained",autoFocus:!0,style:{marginLeft:8},children:[h&&D===0&&l.jsx(Tt,{size:16}),Ze.confirm]})]}),children:[X&&l.jsx(wa,{alternativeLabel:!0,activeStep:D,children:ht.map(({label:te})=>l.jsx(Sa,{children:l.jsx(Ea,{children:te})},te))}),l.jsx(ka,{component:"div",style:{marginTop:24},children:Ze.body}),!!f&&l.jsx(Mo,{severity:"error",style:{width:"100%",marginTop:8},children:f})]}),w&&B&&l.jsx(Jo,{popup:!0,open:!0,forceConnected:!1,className:"launch-from-url-auth",action:!he&&!z?"bind-wallet":"launch-free-blocklet-by-session",checkFn:a.get,checkTimeout:5*60*1e3,onSuccess:we,extraParams:_e,messages:{title:m("setup.keyPair.title"),scan:m("setup.keyPair.scan"),confirm:m("setup.keyPair.confirm"),success:m("setup.keyPair.success")},onClose:de,customItems:z?[]:[l.jsx(ws,{onClick:et})]})]})}Ss.propTypes={defaultUrl:F.string,onCancel:F.func.isRequired,onSuccess:F.func.isRequired,onError:F.func,mode:F.oneOf(["install","component"]),handleText:F.object};const pu={meta:F.object.isRequired,onCancel:F.func.isRequired};function Es({action:e,onSelect:t,onNext:r}){const{t:i}=wt(),s=[{action:"purchase",title:i("store.purchase.purchase.title"),description:i("store.purchase.purchase.description")},{action:"verify",title:i("store.purchase.verify.title"),description:i("store.purchase.verify.description")}];return l.jsxs(l.Fragment,{children:[l.jsx(Ta,{children:s.map(n=>l.jsxs(Ao,{button:!0,selected:e===n.action,onClick:()=>t(n.action),children:[l.jsx(ja,{sx:{minWidth:48},children:n.action==="purchase"?l.jsx(Oa,{style:{color:e==="purchase"?Ti.primary.main:"#AAA",fontSize:32}}):l.jsx(Ca,{style:{color:e==="verify"?Ti.primary.main:"#AAA",fontSize:32}})}),l.jsx(Do,{primary:n.title,secondary:n.description})]},n.action))}),r&&l.jsx(yt,{fullWidth:!0,disabled:!e,variant:"contained",color:"primary",style:{marginTop:16},onClick:r,children:i("common.next")})]})}Es.propTypes={action:F.oneOf(["both","purchase","verify"]).isRequired,onSelect:F.func.isRequired,onNext:F.func.isRequired};function ks({meta:e,onCancel:t,mode:r,handlePaySuccess:i=()=>{}}){const{t:s,locale:n}=wt(),{info:o}=ln(),a=pl(o),[d,h]=q.useState(null),u=new URL(e?.registryUrl).origin,f=$t.getDisplayName({meta:e}),j=async(E,S)=>{const C=({downloadTokenList:D})=>{i({downloadTokenList:D})},_=D=>{Gn.error(D),t(D)};function N(D){return gl(()=>Li.get(D).then(async({data:c})=>{const w=c?.downloadTokenList;if(c.status==="succeed"){if(w&&w.length)await C({downloadTokenList:w});else return await _(s("blocklet.component.missDownloadTokenTip")),!0;return!0}return c.status==="error"?(console.error("vc error: ",c),await _(c?.error),!0):!1}),{interval:1e3})}if(r==="purchase"&&d){const{statusUrl:D}=ml(d);await N(D)}else await C({downloadTokenList:E.downloadTokenList&&S(E.downloadTokenList)})};if(q.useEffect(()=>{if(r==="purchase"){const E=new URL(u);E.pathname="/api/did/verify-purchase-blocklet/token",E.searchParams.set("serverDid",o.did),E.searchParams.set("blockletDid",e?.did);try{Li.get(E.href).then(({data:S})=>{const C=`${S.url}`;h(C)})}catch(S){console.error("get next workflow url error: ",S)}}return()=>{h(null)}},[r]),r==="purchase"&&!d)return"";const m={verify:{action:"verify-purchase-blocklet",checkFn:Ri.create({baseURL:u}).get,extraParams:{serverDid:o.did,blockletDid:e?.did},messages:{title:s("store.purchase.verify.auth.title",{name:f}),scan:s("store.purchase.verify.auth.scan"),confirm:s("store.purchase.verify.auth.confirm"),success:s("store.purchase.verify.auth.success")}},purchase:{action:"acquire-asset",checkFn:Ri.create({baseURL:Zt(u,"/store")}).get,extraParams:{factory:e.nftFactory,nw:d},messages:{title:s("store.purchase.auth.title",{name:f}),scan:s("store.purchase.auth.scan"),confirm:s("store.purchase.auth.confirm"),success:l.jsxs(l.Fragment,{children:[l.jsx("p",{children:s("store.purchase.auth.success")}),l.jsx("p",{children:s("blocklet.component.purchaseComponentSecondCheckTip")})]})}}};return l.jsx(Jo,{open:!0,locale:n,popup:!1,saveConnect:!1,className:"connect",baseUrl:u,onSuccess:j,cancelWhenScanned:t,onClose:t,checkTimeout:60*5e3,webWalletUrl:a,disableClose:!0,showDownload:!1,...m[r]})}ks.propTypes={...pu,handlePaySuccess:F.func,mode:F.oneOf(["verify","purchase"]).isRequired};function Ts({ref:e=null,mode:t,...r}){const[i,s]=q.useState(t!=="both"?t:"verify"),[n,o]=q.useState(t!=="both"?2:1),a=h=>{h!==i&&s(h)},d=()=>{i&&n!==2&&o(2)};return q.useImperativeHandle(e,()=>({onNext:d,getCurrentStep:()=>n})),n===1?l.jsx("div",{style:{maxWidth:520},children:l.jsx(Es,{action:i,onNext:null,onSelect:a})}):l.jsx(ks,{...r,mode:i})}Ts.propTypes={mode:F.oneOf(["both","verify","purchase"]).isRequired,ref:F.any};function mu({...e}){return l.jsx(yt,{className:"bottom-button",variant:"contained",color:"primary",...e})}function js({blocklet:e=null,onStartNow:t=()=>{},children:r=null,disabled:i=!1}){const{t:s}=wt(),n=is();return!e||vl(e.meta)?l.jsx(gu,{children:r}):l.jsxs(vu,{isMobile:n,children:[l.jsx(mu,{className:"start-now",variant:"contained",color:"primary",disabled:i,onClick:()=>t(),children:s("setup.startNow")}),l.jsx(oe,{sx:{display:"flex",alignItems:"center"},children:r})]})}js.propTypes={blocklet:F.object,onStartNow:F.func,children:F.any,disabled:F.bool};const gu=it(oe)`
|
|
221
221
|
width: 100%;
|
|
222
222
|
margin-top: auto;
|
|
223
223
|
padding-top: 24px;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{O as v,j as l}from"./vendor-mui-core-p6jGoroc.js";import{j as B,r}from"./vendor-react-x2lQvn4m.js";import{C as O,D as W}from"./vendor-utils-CtD44yV-.js";import{T as L,a as T}from"./vendor-ux-TkkDR0Gn.js";import{h as d,b as A,m as _}from"./vendor-hooks-zCCbpt45.js";import{A as $,S as F}from"./add-component-core-
|
|
1
|
+
import{O as v,j as l}from"./vendor-mui-core-p6jGoroc.js";import{j as B,r}from"./vendor-react-x2lQvn4m.js";import{C as O,D as W}from"./vendor-utils-CtD44yV-.js";import{T as L,a as T}from"./vendor-ux-TkkDR0Gn.js";import{h as d,b as A,m as _}from"./vendor-hooks-zCCbpt45.js";import{A as $,S as F}from"./add-component-core-BUbtTpoW.js";import{m as K,D as z}from"./index-CDq77s86.js";import"./lottie-web-4koyQiv_.js";import"./item-D9OLZ5b9.js";import"./index-DBs9Ljax.js";import"./delete-confirm-DBhhuh63.js";import"./click-to-copy-DlFJrA7H.js";import"./confirm-_x5prMc6.js";import"./session-CvQ97dDY.js";import"./get-safe-url-70dNOHyP.js";import"./did-address-BdvYNOBf.js";import"./vendor-arcblock-BndcJjQO.js";import"./launch-result-message-gmDOMo-e.js";import"./page-header-CiDBkMEP.js";import"./engine-CbuJOouR.js";import"./config-space-bJO1Pq2d.js";import"./spaces-DVGE8nur.js";import"./api-CpYSt0CS.js";import"./logo-uploader-CnbjQmUt.js";import"./index-CV2-Ra10.js";import"./Google-YsG2REYU.js";import"./cloneDeep-wCAABKRh.js";import"./collapse-BqoeNHou.js";import"./index-E_Fpmc4w.js";import"./index-MGxe3V9B.js";import"./useLocalStorage-DHCQcCRn.js";import"./index-VGO-dEle.js";import"./util-CNKleiqU.js";import"./use-mobile-B8-JPkft.js";import"./content-layout-BFy-gp0u.js";import"./connect-to-CWHsYUA6.js";import"./index-B0stLJYN.js";import"./index-DRYJ0xIl.js";import"./index-BojVbZw0.js";import"./index-DHPu60AO.js";import"./search-4YYphs0l.js";function Me(){const{t:u}=L(),{blocklet:h}=K(),{componentDid:s}=B(),w=v(e=>e.breakpoints.down("md")),t=new URL(window.location.href),f=t.searchParams.get("mode")==="dialog",n=t.searchParams.get("resourceType")||"",m=t.searchParams.get("resourceDid")||s,g=t.searchParams.get("store")||"",C=t.searchParams.get("showFromUrl")!=="false",R=t.searchParams.get("showResourcesSwitch")!=="false",S=t.searchParams.get("enableRunBackground")!=="false",b=t.searchParams.get("showCategory")!=="false",a=h?.meta?.did,i=g.split(",").filter(Boolean).map(e=>{try{return new URL(e.startsWith("http")?e:`https://${e}`).origin}catch(o){return console.error(o),null}}).filter(Boolean),[y,D]=r.useState(i.map(e=>({url:e,name:e.replace("https://","")}))),[E,P]=r.useState(null),[U,j]=r.useState("");r.useEffect(()=>{(async()=>{try{const e=await Promise.all(i.map(async o=>{const x=O(o,"/api/store.json"),{data:M}=await W.get(x);return{url:o,name:M.name}}));D(e||[])}catch(e){console.error(e)}})()},[i.join(",")]);const k=()=>{window.parent.postMessage({event:"resourceDialog.close",componentDid:s},"*")};r.useEffect(()=>{const e=z();return a&&e.connect(),()=>{a&&e.isConnected()&&e.disconnect()}},[a]),d(()=>{window.parent.postMessage({event:"resourceDialog.loaded",componentDid:s},"*")});const c=A(e=>{e.data?.event==="resourceDialog.select"&&e.data?.componentDid===s&&(P(e.data.data),j(e.data.storeUrl))});d(()=>{window.addEventListener("message",c)}),_(()=>{window.removeEventListener("message",c)});const p=({inDialog:e=!0}={})=>l.jsx($,{stores:y,selectedMeta:E,storeUrl:U,resourceType:n,resourceDid:m,mode:"embed",inDialog:e,storageKey:F(`${n}+${m}`),showResourcesSwitch:R,showFromUrl:C,enableRunBackground:S,showCategory:b});return f?l.jsx(T,{className:"resource-dialog",title:u("blocklet.publish.addResource"),maxWidth:!1,fullWidth:!1,PaperProps:{style:w?{width:"100%",height:window.innerHeight}:{maxWidth:1350,minWidth:930,width:"80%"}},onClose:(e,o)=>{o!=="backdropClick"&&k()},showCloseButton:!0,disableEscapeKeyDown:!0,open:!0,children:p()}):p({inDialog:!1})}export{Me as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as t,k as x}from"./vendor-react-x2lQvn4m.js";import{j as e,I as u,at as C,$ as o}from"./vendor-mui-core-p6jGoroc.js";import{b as M,Y as f,f as b}from"./vendor-ux-TkkDR0Gn.js";import{a5 as H}from"./index-
|
|
1
|
+
import{r as t,k as x}from"./vendor-react-x2lQvn4m.js";import{j as e,I as u,at as C,$ as o}from"./vendor-mui-core-p6jGoroc.js";import{b as M,Y as f,f as b}from"./vendor-ux-TkkDR0Gn.js";import{a5 as H}from"./index-CDq77s86.js";import{t as Z}from"./question-mark-circle.svg-YsMacl4Q.js";const g=s=>t.createElement("svg",{width:21,height:20,viewBox:"0 0 21 20",xmlns:"http://www.w3.org/2000/svg",...s},t.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7.60567 17.3203C7.38971 16.9661 7.19606 16.5686 7.02468 16.1402C6.86016 15.7289 6.7127 15.2804 6.58436 14.801C6.01415 15.0849 5.48171 15.439 4.99946 15.855C5.7556 16.5015 6.63848 17.004 7.60567 17.3203ZM8.26264 15.645C8.10246 15.2446 7.95842 14.7971 7.83425 14.3104C8.53612 14.104 9.26539 13.9991 9.9998 14H10.0015C10.7359 13.9991 11.4652 14.104 12.167 14.3104C12.0429 14.7971 11.8988 15.2446 11.7386 15.645C11.4556 16.3525 11.1353 16.8804 10.8137 17.2204C10.4935 17.559 10.2185 17.6667 10.0006 17.6667C9.78281 17.6667 9.50783 17.559 9.18757 17.2204C8.86599 16.8804 8.54566 16.3525 8.26264 15.645ZM10.0007 12.6667C10.8258 12.6657 11.6453 12.7785 12.4365 13.0005C12.5533 12.274 12.6295 11.49 12.6565 10.6666H7.34483C7.37175 11.49 7.448 12.274 7.56482 13.0006C8.35599 12.7785 9.17556 12.6657 10.0007 12.6667ZM7.34483 9.33331C7.37175 8.50999 7.448 7.72596 7.56482 6.99945C8.35598 7.22152 9.17556 7.33433 10.0007 7.33334C10.8258 7.33433 11.6453 7.22153 12.4365 6.99947C12.5533 7.72597 12.6295 8.51 12.6565 9.33331H7.34483ZM13.9905 10.6666C13.9603 11.6495 13.8639 12.5916 13.7104 13.4645C14.5207 13.8311 15.2715 14.3159 15.9385 14.9026C16.9065 13.7315 17.5347 12.2691 17.6722 10.6666H13.9905ZM17.6721 9.33331H13.9904C13.9603 8.35043 13.8639 7.40842 13.7104 6.5355C14.5207 6.16891 15.2715 5.68412 15.9385 5.09743C16.9065 6.26854 17.5347 7.73084 17.6721 9.33331ZM19.0006 10.0017C18.9997 14.9715 14.9706 19 10.0006 19H10.0006C5.03005 19 1.00061 14.9706 1.00061 10C1.00061 9.99999 1.00061 9.99999 1.00061 9.99998C1.00062 5.02943 5.03005 1 10.0006 1C14.9712 1 19.0006 5.02944 19.0006 10C19.0006 10.0006 19.0006 10.0011 19.0006 10.0017ZM2.32907 9.33331C2.46651 7.73082 3.09476 6.2685 4.0628 5.09738C4.72975 5.68407 5.48055 6.16888 6.29084 6.53548C6.13742 7.40841 6.041 8.35042 6.01083 9.33331H2.32907ZM2.32907 10.6666H6.01083C6.04099 11.6496 6.13742 12.5916 6.29084 13.4645C5.48055 13.8311 4.72975 14.3159 4.06281 14.9026C3.09475 13.7315 2.46649 12.2692 2.32907 10.6666ZM12.9766 16.1402C13.1411 15.7289 13.2886 15.2804 13.4169 14.8009C13.9871 15.0849 14.5196 15.4389 15.0018 15.8549C14.2457 16.5014 13.3628 17.004 12.3956 17.3202C12.6116 16.9661 12.8052 16.5686 12.9766 16.1402ZM12.3956 2.67976C13.3628 2.996 14.2457 3.49858 15.0018 4.14508C14.5196 4.56106 13.9871 4.91516 13.4169 5.19908C13.2886 4.71963 13.1411 4.2711 12.9766 3.85979C12.8052 3.43137 12.6116 3.03387 12.3956 2.67976ZM11.7386 4.355C11.8988 4.75545 12.0429 5.20292 12.167 5.68962C11.4652 5.89603 10.7359 6.00096 10.0015 6.00001H9.9998C9.26539 6.00096 8.53612 5.89602 7.83424 5.68961C7.95841 5.20291 8.10246 4.75544 8.26264 4.355C8.54566 3.64747 8.86599 3.11964 9.18757 2.7796C9.50783 2.44096 9.78281 2.33333 10.0006 2.33333C10.2185 2.33333 10.4935 2.44096 10.8137 2.7796C11.1353 3.11964 11.4556 3.64747 11.7386 4.355ZM7.02468 3.85979C6.86015 4.2711 6.71269 4.71961 6.58436 5.19906C6.01414 4.91513 5.4817 4.56103 4.99945 4.14504C5.7556 3.49854 6.63848 2.99596 7.60567 2.67973C7.38971 3.03385 7.19606 3.43136 7.02468 3.85979Z",fill:"currentColor"}));function k({SessionContext:s,extraItems:n=[],showLocale:r=!0,showHelper:l=!0,showSessionManager:c=!0,sessionManagerProps:i={}}){const{session:d}=t.useContext(s),{locale:p}=t.useContext(M),w=x(),h=()=>{if(w.pathname.indexOf("/store")>-1){window.open("https://www.arcblock.io/content/docs/createblocklet","_blank");return}window.open("https://www.arcblock.io/content/docs/blocklet-developer","_blank")};return e.jsxs(e.Fragment,{children:[n.map((a,m)=>t.cloneElement(a,{key:m})),r&&e.jsx(v,{"data-cy":"locale-addon",icon:g,size:23,showText:!1,className:"locale-addon"}),e.jsx(H,{}),l&&e.jsx(u,{onClick:h,children:e.jsx(Z,{})}),c&&e.jsx(j,{locale:p,session:d,size:24,showRole:!0,...i,showManageBlocklet:!1})]})}k.propTypes={SessionContext:o.object.isRequired,extraItems:o.array,showLocale:o.bool,showSessionManager:o.bool,showHelper:o.bool,sessionManagerProps:o.object};const j=C(b)`
|
|
2
2
|
.user-addon {
|
|
3
3
|
.user-avatar {
|
|
4
4
|
width: 28px;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as P}from"./vendor-react-x2lQvn4m.js";import{j as k,p as ce,ak as T,V as qe,cE as Ne,T as ee,$ as F,b6 as Me,C as Pe,bC as Fe,aX as ze,at as je,Y as Je,b1 as le,G as Be,H as Ue,cF as ke,bb as ne,a7 as V,cG as Ve,am as ge,bt as ye}from"./vendor-mui-core-p6jGoroc.js";import{_ as te,Y as We,$ as Se,f as Ke,K as He,b3 as Ge,p as Ze,b4 as Ye,c as Qe,az as be,ax as Re,ay as Ae,M as Z}from"./index-
|
|
1
|
+
import{r as P}from"./vendor-react-x2lQvn4m.js";import{j as k,p as ce,ak as T,V as qe,cE as Ne,T as ee,$ as F,b6 as Me,C as Pe,bC as Fe,aX as ze,at as je,Y as Je,b1 as le,G as Be,H as Ue,cF as ke,bb as ne,a7 as V,cG as Ve,am as ge,bt as ye}from"./vendor-mui-core-p6jGoroc.js";import{_ as te,Y as We,$ as Se,f as Ke,K as He,b3 as Ge,p as Ze,b4 as Ye,c as Qe,az as be,ax as Re,ay as Ae,M as Z}from"./index-CDq77s86.js";import{w as ue,P as Xe}from"./permission-3PNyBKZ2.js";import{T as oe,n as G,H,a as Oe,a7 as et,a8 as tt,B as rt,q as K,e as ve,b as st}from"./vendor-ux-TkkDR0Gn.js";import{l as Ee}from"./vendor-hooks-zCCbpt45.js";import{C as me}from"./confirm-_x5prMc6.js";import{f as ie}from"./index-DBs9Ljax.js";import{u as nt}from"./useSetState-BWrXo9eH.js";import{u as Ce}from"./session-CvQ97dDY.js";import{S as U}from"./section-iFIMehPS.js";import{C as at}from"./click-to-copy-DlFJrA7H.js";import{u as De}from"./dashboard-e9cJiXmU.js";import{v as it,$ as ot}from"./vendor-utils-CtD44yV-.js";import{v as lt}from"./index-VGO-dEle.js";import{W as ct}from"./did-address-BdvYNOBf.js";import{V as ut}from"./status-CxWCFwty.js";import"./vendor-arcblock-BndcJjQO.js";import"./lottie-web-4koyQiv_.js";import"./useLocalStorage-DHCQcCRn.js";import"./get-safe-url-70dNOHyP.js";import"./use-blocklet-logo-C7qZcidt.js";import"./dot-DWse_kXZ.js";import"./useAsync-C8Ma6muj.js";import"./index-glbEl-Pn.js";import"./over-due-invoice-payment-CuQ5h3hN.js";import"./use-mobile-DpkDXDwi.js";import"./omit-C6lXG4Q2.js";const ft=localStorage.getItem("enableDebug")==="true";function dt({teamDid:$,size:D="small",...L}){const{t:E}=oe(),{api:j}=te(),[w,p]=P.useState(!1),[i,g]=P.useState(null),m=()=>{p(!1),g(null)},f=async()=>{try{p(!0);const a=await j.clearCache({input:{teamDid:$}});H.success(E("blocklet.config.clearCache.success",{count:a.removed?.length||0}))}catch(a){H.error(ie(a))}finally{p(!1),g(null)}},e={title:E("blocklet.config.clearCache.title"),description:E("blocklet.config.clearCache.description"),confirm:E("common.confirm"),cancel:E("common.cancel"),onConfirm:f,onCancel:m};return k.jsxs("div",{...L,children:[k.jsxs(G,{onClick:()=>g(e),color:"error",variant:"outlined",size:D,children:[w?k.jsx(ce,{size:16,style:{marginRight:5}}):null,E("blocklet.config.clearCache.action")]}),i&&k.jsx(me,{title:i.title,description:i.description,confirm:i.confirm,cancel:i.cancel,onConfirm:i.onConfirm,onCancel:i.onCancel})]})}function Ie({onChange:$=()=>{},disabled:D=!1,loading:L=!1,inService:E=!1}){const{t:j}=oe(),{api:w,session:p}=Ce(),{blocklet:i}=We(),[g,m]=nt({newAppSk:"",isConnectOpen:!1,confirmDialogOpen:!1}),f=()=>m({isConnectOpen:!1}),e=()=>{if(Ke.isInProgress(i.status)){H.error(j("blocklet.error.isInProgress"));return}m({confirmDialogOpen:!0})};return k.jsxs(k.Fragment,{children:[k.jsx(U,{title:j("blocklet.config.migrate.button"),desc:j("blocklet.config.migrate.description"),children:k.jsx(T,{sx:{alignSelf:{xs:"flex-start",md:"flex-end"}},children:k.jsxs(qe,{style:{flexShrink:0},variant:"contained",color:"primary",size:"small","data-cy":"config-did",disabled:D||L,onClick:e,children:[k.jsx(Ne,{style:{fontSize:"1.3em",marginRight:4}}),j("blocklet.config.migrate.button")]})})}),k.jsxs(k.Fragment,{children:[g.isConnectOpen&&k.jsx(Se,{popup:!0,open:g.isConnectOpen,forceConnected:!1,saveConnect:!1,action:"rotate-key-pair",checkFn:w.get,checkTimeout:5*60*1e3,onSuccess:()=>{$(),E&&p.logout(),f()},extraParams:{appDid:i.appDid},messages:{title:j("setup.keyPair.title"),scan:j("setup.keyPair.scan"),confirm:j("setup.keyPair.confirm"),success:j("setup.keyPair.success")},onClose:f}),g.confirmDialogOpen&&k.jsx(me,{title:k.jsx(ee,{sx:{fontSize:"20px",fontWeight:"500"},children:j("blocklet.config.migrate.title")}),description:k.jsx(ee,{sx:{fontSize:"14px",color:"#9397A1"},children:j("blocklet.config.migrate.confirm")}),confirm:j("common.confirm"),cancel:j("common.cancel"),onConfirm:()=>m({confirmDialogOpen:!1,isConnectOpen:!0}),onCancel:()=>m({confirmDialogOpen:!1})})]})]})}Ie.propTypes={onChange:F.func,disabled:F.bool,loading:F.bool,inService:F.bool};function Te({onCancel:$,onSuccess:D,onError:L=()=>{}}){const{api:E}=P.useContext(He),[j,w]=P.useState(!1),{t:p,locale:i}=oe(),[g,m]=P.useState(""),[f,e]=P.useState(!1),[a,n]=P.useState(0),[r,t]=P.useState(""),{endpoint:l}=De(),[s,o]=P.useState(!1),u=c=>{m(null),w(!0);try{t(c.result),n(_.length-1)}catch(h){const b=ie(h);m(b),L(h)}finally{w(!1)}},d=()=>{e(!0),n(1)},y=()=>{e(!1),n(0)},_=[{body:k.jsxs(T,{children:[k.jsx(ee,{children:p("team.transferApp.transferDialog.tips.progress")}),k.jsx(ee,{sx:{mt:3,mb:2},children:p("team.transferApp.transferDialog.tips.newOwnerPermissions")})]}),cancel:p("common.cancel"),confirm:p("team.transferApp.transferDialog.createTransferLink"),onCancel:$,onConfirm:d},{cancel:p("common.cancel"),confirm:p("team.transferApp.transferDialog.createTransferLink"),body:()=>k.jsx(Se,{action:"transfer-app-owner",open:f,locale:i,checkFn:E.get,onClose:y,onSuccess:u,checkTimeout:5*60*1e3,extraParams:{},messages:{title:p("team.transferApp.connectDialog.title"),scan:p("team.transferApp.connectDialog.scan"),confirm:p("team.transferApp.connectDialog.confirm"),success:p("team.transferApp.connectDialog.success")},popup:!0})},{body:()=>{const c=Ge({transferId:r.transferId,endpoint:l});return k.jsxs(k.Fragment,{children:[k.jsx(T,{component:Y,dangerouslySetInnerHTML:{__html:p("team.transferApp.transferDialog.createSuccessTip1")}}),k.jsx(T,{component:Y,sx:{mt:2},children:k.jsx(Y,{children:p("team.transferApp.transferDialog.createSuccessTip3")})}),k.jsxs(T,{children:[k.jsx(T,{component:Y,sx:{mt:2},children:k.jsx(Y,{children:p("team.transferApp.transferDialog.createSuccessTip2",{expireDate:Ze(r.expireDate,i)})})}),k.jsx(T,{sx:{my:1},children:k.jsx(at,{children:c})})]}),k.jsx("div",{children:k.jsx(Me,{value:"end",control:k.jsx(Pe,{checked:s,onChange:h=>o(h.target.checked)}),label:p("team.transferApp.transferDialog.iKnow"),labelPlacement:"end"})})]})},confirm:p("common.confirm"),onConfirm:D}],v=_[a];return k.jsxs(Oe,{title:k.jsx(Y,{className:"title",children:p("team.transferApp.transferDialog.title")}),fullWidth:!0,open:!0,showCloseButton:!1,actions:k.jsxs(k.Fragment,{children:[v.cancel&&k.jsx(G,{onClick:v.onCancel,color:"inherit",children:v.cancel}),k.jsxs(G,{onClick:v.onConfirm,color:"error",disabled:j||a===_.length-1&&!s,variant:"contained",autoFocus:!0,children:[j&&k.jsx(ce,{size:16}),v.confirm]})]}),children:[k.jsx(Fe,{component:"div",children:typeof v.body=="function"?v.body():v.body}),!!g&&k.jsx(ze,{severity:"error",variant:"icon",children:g})]})}Te.propTypes={onCancel:F.func.isRequired,onSuccess:F.func.isRequired,onError:F.func};const Y=je.div`
|
|
2
2
|
font-size: 16px;
|
|
3
3
|
font-weight: bold;
|
|
4
4
|
&.title {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as E,A as k}from"./vendor-utils-CtD44yV-.js";import{_ as T,Y as j,c as M}from"./index-
|
|
1
|
+
import{C as E,A as k}from"./vendor-utils-CtD44yV-.js";import{_ as T,Y as j,c as M}from"./index-CDq77s86.js";import{r as e}from"./vendor-react-x2lQvn4m.js";import{T as B}from"./vendor-ux-TkkDR0Gn.js";import{u as H}from"./use-mobile-B8-JPkft.js";import{J as I,j as o,ak as w,p as N}from"./vendor-mui-core-p6jGoroc.js";import"./vendor-arcblock-BndcJjQO.js";import"./vendor-hooks-zCCbpt45.js";import"./lottie-web-4koyQiv_.js";function J(){const{info:x,inService:g}=T(),{blocklet:y}=j(),{locale:p}=B(),u=e.useRef(null),r=I(),[L,R]=e.useState(0),f=H(),[t,S]=e.useState(!0),s=e.useRef(null);let a="";g?a=M.WELLKNOWN_SERVICE_PATH_PREFIX:a=x.routing.adminPath;const c=new URLSearchParams;g?c.set("appUrl",window.blocklet.appUrl):c.set("authKey","__sst"),c.set("schemaKey",E(window.location.origin,a,`/api/theme?id=${encodeURIComponent(y.meta.did)}`));const l=e.useCallback(()=>{if(s.current){const n=k(JSON.parse(JSON.stringify(r)),["palette","typography","shape","direction","breakpoints","mixins","shadows","transitions","zIndex"]);s.current.contentWindow.postMessage({type:"SEND_THEME",payload:n},window.location.origin)}},[r]),d=e.useCallback(()=>{s.current&&s.current.contentWindow.postMessage({type:"SEND_LOCALE",payload:p},window.location.origin)},[p]);return e.useEffect(()=>{const n=i=>{i.origin===window.location.origin&&(i.data.type==="REQUEST_THEME"&&l(),i.data.type==="THEME_BUILDER_LOADED"&&(d(),S(!1)))};return window.addEventListener("message",n),()=>{window.removeEventListener("message",n)}},[l,d]),e.useEffect(()=>{t===!1&&l()},[r,t,l]),e.useEffect(()=>{t===!1&&d()},[p,t,d]),e.useEffect(()=>{const n=document.querySelector("#arc__dashboard-main"),i=document.querySelector(".dashboard-content"),m=()=>{if(u.current){const{height:b}=n.getBoundingClientRect(),{top:C}=i.getBoundingClientRect(),{top:_}=u.current.getBoundingClientRect();let h=b-_+C-(f?108:164);f&&(h=Math.min(h,600)),R(h)}};return m(),window.addEventListener("resize",m),()=>{window.removeEventListener("resize",m)}},[f,r]),o.jsxs(o.Fragment,{children:[o.jsx(w,{ref:u}),t&&o.jsx(w,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"500px"},children:o.jsx(N,{})}),o.jsx("iframe",{title:"Theme Builder",ref:s,src:`${E(window.location.origin,a,"/hosted/theme-builder/")}?${c.toString()}`,style:{border:0,width:"100%",height:`${L}px`,display:t?"none":"block"}})]})}export{J as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ct as o,cu as l,cv as r,cw as n}from"./index-
|
|
1
|
+
import{ct as o,cu as l,cv as r,cw as n}from"./index-CDq77s86.js";import{r as e}from"./vendor-react-x2lQvn4m.js";const i=Object.freeze(Object.defineProperty({__proto__:null,default:o},Symbol.toStringTag,{value:"Module"})),u=Object.freeze(Object.defineProperty({__proto__:null,default:l},Symbol.toStringTag,{value:"Module"})),d=Object.freeze(Object.defineProperty({__proto__:null,default:r},Symbol.toStringTag,{value:"Module"})),s=Object.freeze(Object.defineProperty({__proto__:null,default:n},Symbol.toStringTag,{value:"Module"})),f=t=>e.createElement("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},e.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.0608 6.75011L11.5304 7.28044L8.70722 10.1036C8.31669 10.4942 7.68353 10.4942 7.293 10.1036L4.46978 7.28044L3.93945 6.75011L5.00011 5.68945L5.53044 6.21978L8.00011 8.68945L10.4698 6.21978L11.0001 5.68945L12.0608 6.75011Z",fill:"currentColor"}));export{d as E,u as L,i as P,s as T,f as l};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{H as N,T as E,A as U,S as R,M as H,C as F}from"./vendor-ux-TkkDR0Gn.js";import{_ as O,c as T}from"./index-
|
|
1
|
+
import{H as N,T as E,A as U,S as R,M as H,C as F}from"./vendor-ux-TkkDR0Gn.js";import{_ as O,c as T}from"./index-CDq77s86.js";import{j as e,J as W,ak as p,b4 as Z,T as y,am as G,bt as K,I as _,bV as X,bW as J,p as q,E as Q,D as Y,bu as ee,M as te,bX as oe,at as re}from"./vendor-mui-core-p6jGoroc.js";import{p as se}from"./util-B-cMjJCC.js";import{r as a,L as ae}from"./vendor-react-x2lQvn4m.js";import{u as ne}from"./useLocalStorage-DHCQcCRn.js";import{M as $}from"./index-E_Fpmc4w.js";import{d as ie,e as z}from"./vendor-utils-CtD44yV-.js";import{S as I}from"./shorten-label-OzRq4VRH.js";import{r as V}from"./index-BSmqpzfQ.js";import{u as le}from"./dashboard-e9cJiXmU.js";import"./vendor-hooks-zCCbpt45.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-BndcJjQO.js";import"./base32-6sm6N7JR.js";import"./index-DBs9Ljax.js";import"./confirm-_x5prMc6.js";import"./get-safe-url-70dNOHyP.js";import"./session-CvQ97dDY.js";import"./use-blocklet-logo-C7qZcidt.js";import"./dot-DWse_kXZ.js";import"./useAsync-C8Ma6muj.js";import"./useSetState-BWrXo9eH.js";import"./index-glbEl-Pn.js";import"./over-due-invoice-payment-CuQ5h3hN.js";import"./use-mobile-DpkDXDwi.js";const B=a.createContext({}),{Provider:ce,Consumer:Fe}=B;function de(){return localStorage.getItem("audit-log-page-size")&&Number(localStorage.getItem("audit-log-page-size"))||10}function pe({children:t,scope:l="",categories:o=[],showScope:n,scopeFormatter:u}){const{api:g,info:L}=O(),[f,h]=a.useState([]),[c,x]=a.useState({total:0,pageSize:de(),pageCount:0,page:1}),[m,d]=a.useState(!1),[v,r]=a.useState(""),[i,j]=ne(`audit-log-category-${l}`,"all"),w=[{value:"all",label:"All",description:""},{value:"blocklet",label:"Blocklet Management",description:""},{value:"server",label:"Server Management",description:""},{value:"team",label:"Team Management",description:""},{value:"security",label:"Security",description:""},{value:"certificates",label:"Certificate Management",description:""},{value:"integrations",label:"Integration Management",description:""},{value:"gateway",label:"Gateway",description:""}].filter(b=>o.length?b.value==="all"||o.includes(b.value):!0),S=async({page:b=1,pageSize:s=20,silent:k=!0}={})=>{if(!m){k||d(!0);try{const C=await g.getAuditLogs({input:{paging:{page:b,pageSize:s},category:i==="all"?"":i,scope:l,actionOrContent:v}});n&&(C.list||[]).forEach(A=>{A.scope!==L.did&&(A.link=`/blocklets/${A.scope}/components`)}),h(C.list),x(C.paging),d(!1)}catch(C){N.error(C.message),d(!1)}}};a.useEffect(()=>{localStorage.setItem("audit-log-page-size",c.pageSize)},[c.pageSize]),a.useEffect(()=>{S({page:1,pageSize:c.pageSize,silent:!1})},[]),a.useEffect(()=>{S({page:1,pageSize:c.pageSize,silent:!1})},[i,v]);const P={loading:m,fetch:S,filter:{category:i,scope:l},categories:w,setCategory:j,data:f,paging:c,setPaging:x,showScope:n,scopeFormatter:u,actionOrContent:v,setActionOrContent:r};return e.jsx(ce,{value:{auditLogs:P},children:t})}function D(){const{auditLogs:t}=a.useContext(B);return t}function ue(t){if(!t)return[];const l=/\[([^\]]+)\]\(([^)]+)\)/g,o=[];let n;for(;(n=l.exec(t))!==null;)o.push({text:n[1],url:n[2]});return o}const ge=`
|
|
2
2
|
<svg style="width:38px;height:38px;" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
3
3
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M50.152 10.6417L31.72 0L13.288 10.6417V24.7942L1 31.8887V53.1722L19.432 63.8139L31.6902 56.7366L31.72 56.7538L31.7498 56.7366L44.008 63.8139L62.44 53.1722V31.8887L50.152 24.7942V10.6417ZM60.52 32.9972L48.232 25.9027V11.7502L31.72 2.21703L15.208 11.7502V25.9028L2.92 32.9972V52.0636L19.432 61.5968L31.6902 54.5196L31.72 54.5368L31.7498 54.5196L44.008 61.5968L60.52 52.0636V32.9972Z" fill="url(#paint0_linear_606_96)"/>
|
|
4
4
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M50.1521 24.8307L31.7201 14.189L13.2881 24.8307V46.1141L31.7201 56.7558L50.1521 46.1141V24.8307ZM15.2081 25.9392L31.7201 16.406L48.2321 25.9392V45.0056L31.7201 54.5388L15.2081 45.0056V25.9392ZM28.5464 23.0464C28.6641 22.6342 29.0408 22.3501 29.4695 22.3501H33.9707C34.3993 22.3501 34.776 22.6342 34.8938 23.0464L35.7504 26.0447L37.8696 27.2681L40.8945 26.5109C41.3103 26.4068 41.7447 26.591 41.959 26.9622L44.2096 30.8604C44.424 31.2316 44.3662 31.6998 44.0682 32.0079L41.8999 34.2489V36.6959L44.0682 38.9369C44.3662 39.245 44.424 39.7133 44.2096 40.0845L41.959 43.9827C41.7447 44.3539 41.3103 44.538 40.8945 44.4339L37.8696 43.6767L35.7504 44.9002L34.8938 47.8984C34.776 48.3106 34.3993 48.5947 33.9707 48.5947H29.4695C29.0408 48.5947 28.6641 48.3106 28.5464 47.8984L27.6897 44.9002L25.5706 43.6767L22.5457 44.4339C22.1299 44.538 21.6955 44.3539 21.4812 43.9827L19.2305 40.0845C19.0162 39.7133 19.0739 39.245 19.372 38.9369L21.5402 36.6959V34.2489L19.372 32.0079C19.0739 31.6998 19.0162 31.2316 19.2305 30.8604L21.4812 26.9622C21.6955 26.591 22.1299 26.4068 22.5457 26.5109L25.5706 27.2681L27.6897 26.0447L28.5464 23.0464ZM28.9861 27.5132C29.2018 27.3887 29.3607 27.1851 29.4292 26.9456L30.1936 24.2701H33.2466L34.011 26.9456C34.0794 27.1851 34.2383 27.3887 34.4541 27.5132L37.2459 29.1251C37.4617 29.2497 37.7174 29.2855 37.9591 29.225L40.6583 28.5493L42.1848 31.1932L40.25 33.193C40.0768 33.372 39.9799 33.6114 39.9799 33.8605V37.0843C39.9799 37.3334 40.0768 37.5728 40.25 37.7518L42.1848 39.7516L40.6583 42.3955L37.9591 41.7198C37.7174 41.6593 37.4617 41.6951 37.2459 41.8197L34.4541 43.4316C34.2383 43.5561 34.0794 43.7597 34.011 43.9992L33.2466 46.6747H30.1936L29.4292 43.9992C29.3607 43.7597 29.2018 43.5561 28.9861 43.4316L26.1942 41.8197C25.9785 41.6951 25.7228 41.6593 25.4811 41.7198L22.7819 42.3955L21.2554 39.7516L23.1902 37.7518C23.3634 37.5728 23.4602 37.3334 23.4602 37.0843V33.8605C23.4602 33.6114 23.3634 33.372 23.1902 33.193L21.2554 31.1932L22.7819 28.5493L25.4811 29.225C25.7228 29.2855 25.9785 29.2497 26.1942 29.1251L28.9861 27.5132ZM31.7201 41.6407C28.3134 41.6407 25.5517 38.8791 25.5517 35.4724C25.5517 32.0657 28.3134 29.3041 31.7201 29.3041C35.1268 29.3041 37.8884 32.0657 37.8884 35.4724C37.8884 38.8791 35.1268 41.6407 31.7201 41.6407ZM35.9684 35.4724C35.9684 37.8187 34.0664 39.7207 31.7201 39.7207C29.3738 39.7207 27.4717 37.8187 27.4717 35.4724C27.4717 33.1261 29.3738 31.2241 31.7201 31.2241C34.0664 31.2241 35.9684 33.1261 35.9684 35.4724Z" fill="url(#paint1_linear_606_96)"/>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{O as A,j as e,ak as t,p as E,V as l,b3 as W,T as o,b4 as z,am as I,b5 as R,b6 as L,C as O,a7 as T,a$ as f,b1 as F}from"./vendor-mui-core-p6jGoroc.js";import{r as x}from"./vendor-react-x2lQvn4m.js";import{l as D}from"./vendor-hooks-zCCbpt45.js";import{C as b}from"./vendor-utils-CtD44yV-.js";import{a as B,c as u,t as H,H as U,G as K,e as M}from"./index-
|
|
1
|
+
import{O as A,j as e,ak as t,p as E,V as l,b3 as W,T as o,b4 as z,am as I,b5 as R,b6 as L,C as O,a7 as T,a$ as f,b1 as F}from"./vendor-mui-core-p6jGoroc.js";import{r as x}from"./vendor-react-x2lQvn4m.js";import{l as D}from"./vendor-hooks-zCCbpt45.js";import{C as b}from"./vendor-utils-CtD44yV-.js";import{a as B,c as u,t as H,H as U,G as K,e as M}from"./index-CDq77s86.js";import{K as p}from"./landing-page-C4ZUBLGU.js";import{T as V,F as y}from"./vendor-ux-TkkDR0Gn.js";import{W as $}from"./did-address-BdvYNOBf.js";import"./vendor-arcblock-BndcJjQO.js";import"./lottie-web-4koyQiv_.js";function re(){const{searchParams:r}=new URL(window.location.href),{session:d}=B(),{t:c}=V(),m=r.get("client_id"),_=r.get("scope")||"profile:read",[g,w]=x.useState(_.split(" ").filter(Boolean)),v=A("(max-width: 600px)"),C=b(window.location.origin,u.WELLKNOWN_SERVICE_PATH_PREFIX,"/oauth/authorize"),k=x.useCallback(i=>i?i.startsWith("http")?i:`${b(u.WELLKNOWN_SERVICE_PATH_PREFIX,"/api/media/upload",window.blocklet.appPid)}/${i}`:"",[]),[h,j]=D({client:null,loading:!0});x.useEffect(()=>{(async()=>{const{data:n}=await M.get("/oauth/client",{params:{clientId:m}});j({client:n,loading:!1})})()},[m,j]);const S=i=>{i!=="profile:read"&&w(n=>n.includes(i)?n.filter(P=>P!==i):[...n,i])};if(h.loading||!d?.user)return e.jsx(p,{did:window.blocklet?.appPid,standalone:!0,children:e.jsx(t,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"},children:e.jsx(E,{})})});if(!h.client)return e.jsx(p,{did:window.blocklet?.appPid,standalone:!0,children:e.jsx(t,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"},children:e.jsx(H,{style:{backgroundColor:"transparent"},status:"error",title:c("notFoundOauthClient"),extra:e.jsx(l,{variant:"outlined",color:"primary",size:"small",startIcon:e.jsx(W,{}),href:"/",style:{borderRadius:4},children:c("connectCli.home")})})})});const{client:s}=h,{user:a}=d,N=(s.scope||"").split(" ");return e.jsxs(p,{did:window.blocklet?.appPid,standalone:!0,children:[e.jsx(U,{children:e.jsx("title",{children:c("oauth.authorize")})}),e.jsx(K,{hideCloseButton:!0,children:e.jsxs(t,{sx:{display:"flex",flexDirection:"column",p:{xs:2,lg:3,xl:4},pt:{xs:3,xl:4},bgcolor:"background.paper"},className:"page-authorize",children:[e.jsxs(t,{sx:{textAlign:"center",mb:2},children:[e.jsxs(t,{sx:{display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:[e.jsx(y,{src:window.blocklet?.appLogo,alt:"Server",width:48,height:48}),e.jsxs(t,{sx:{mx:2,display:"flex",alignItems:"center","& .dot":{width:8,height:8,borderRadius:"50%",bgcolor:"divider",mx:.5}},children:[e.jsx(t,{className:"dot"}),e.jsx(t,{className:"dot"}),e.jsx(t,{className:"dot"})]}),e.jsx(y,{src:k(s.logo_uri),alt:s.client_name,width:48,height:48})]}),e.jsxs(o,{sx:{mb:1,fontSize:"1.2rem","& .app-name":{color:"primary.main"}},children:["Authorize ",e.jsx("span",{className:"app-name",children:s.client_name})]})]}),e.jsxs(t,{sx:{display:"flex",alignItems:"center",width:"100%",overflow:"hidden",mb:3,p:2,border:"1px solid",borderColor:"divider",borderRadius:1},className:"info",children:[e.jsx(z,{src:a.avatar,style:{width:48,height:48,backgroundColor:"transparent",marginRight:16}}),e.jsxs(t,{sx:{flex:1,overflow:"hidden"},children:[e.jsx(I,{title:a.fullName,children:e.jsx(t,{className:"name",sx:{flex:1,overflow:"hidden",textOverflow:"ellipsis"},children:a.fullName})}),e.jsx(t,{className:"did",children:e.jsx($,{compact:!0,responsive:!1,did:a.did,showQrcode:!v})})]})]}),e.jsxs(o,{variant:"subtitle1",sx:{mb:2,fontWeight:500},children:["Allow ",s.client_name," to do the following on your behalf:"]}),e.jsxs(t,{sx:{border:"1px solid",borderColor:"divider",borderRadius:2,overflow:"hidden"},children:[e.jsx(t,{sx:{p:2},children:e.jsx(R,{children:Object.entries(u.OAUTH_SCOPES).filter(([i])=>N.includes(i)).map(([i,n])=>e.jsx(L,{control:e.jsx(O,{checked:g.includes(i),onChange:()=>S(i),disabled:i==="profile:read"||["blocklet:read","blocklet:write"].includes(i)&&!["owner","admin","member"].includes(a.role),color:"primary",sx:{"&.Mui-checked":{color:"success.main"}}}),label:e.jsx(t,{children:e.jsx(o,{variant:"body1",sx:{fontWeight:500},children:n})}),sx:{mb:0}},i))})}),(s.tos_uri||s.policy_uri)&&e.jsxs(e.Fragment,{children:[e.jsx(T,{}),e.jsx(t,{sx:{height:1,bgcolor:"divider"}}),e.jsx(t,{sx:{p:2,color:"text.secondary"},children:e.jsxs(o,{variant:"body2",children:["By authorize the access, you also agree with the"," ",!!s.tos_uri&&e.jsx(f,{href:s.tos_uri,target:"_blank",children:"Terms of Use"}),!!s.tos_uri&&!!s.policy_uri&&" and ",!!s.policy_uri&&e.jsx(f,{href:s.policy_uri,target:"_blank",children:"Privacy Policy"})]})})]})]}),e.jsxs("form",{method:"POST",action:C,children:[r.get("client_id")&&e.jsx("input",{type:"hidden",name:"client_id",value:r.get("client_id")}),r.get("response_type")&&e.jsx("input",{type:"hidden",name:"response_type",value:r.get("response_type")}),r.get("redirect_uri")&&e.jsx("input",{type:"hidden",name:"redirect_uri",value:r.get("redirect_uri")}),r.get("code_challenge")&&e.jsx("input",{type:"hidden",name:"code_challenge",value:r.get("code_challenge")}),r.get("code_challenge_method")&&e.jsx("input",{type:"hidden",name:"code_challenge_method",value:r.get("code_challenge_method")}),r.get("state")&&e.jsx("input",{type:"hidden",name:"state",value:r.get("state")}),e.jsx("input",{type:"hidden",name:"scope",value:g.join(" ")}),e.jsx(t,{sx:{mt:"auto",pt:3},children:e.jsxs(F,{direction:"row",spacing:2,children:[e.jsx(l,{variant:"outlined",size:"large",fullWidth:!0,type:"submit",name:"action",value:"deny",children:"Cancel"}),e.jsx(l,{variant:"contained",size:"large",fullWidth:!0,type:"submit",name:"action",value:"allow",children:"Authorize"})]})}),r.get("redirect_uri")&&e.jsxs(t,{sx:{mt:3,textAlign:"center"},children:[e.jsx(o,{variant:"body2",sx:{color:"text.secondary"},children:"You will be redirected to"}),e.jsx(o,{variant:"body2",sx:{color:"text.secondary",wordBreak:"break-all"},children:r.get("redirect_uri")})]}),e.jsx(t,{sx:{mt:2,textAlign:"center"},children:e.jsxs(o,{variant:"body2",children:["Not you?"," ",e.jsx(l,{variant:"text",color:"primary",onClick:()=>d.switchDid(),sx:{p:0,minWidth:"auto",textTransform:"none",verticalAlign:"baseline",fontWeight:"inherit",fontSize:"inherit","&:hover":{background:"none",textDecoration:"underline"}},children:"Use another account"})]})})]})]})})]})}export{re as default};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-
|
|
2
|
-
import{T as fe,_ as be}from"./vendor-ux-TkkDR0Gn.js";import{j as e,b1 as U,T as E,ak as x,b4 as je,am as J,I as A,bR as Y,a1 as se,at as ve,bB as ye,a3 as we,bv as Ce,H as Z,aJ as Se,bS as Ie,W as ke,V as W,$ as k}from"./vendor-mui-core-p6jGoroc.js";import{c as D}from"./index-S9T-sBWO.js";import{E as N}from"./empty-spinner-CpvmEmwT.js";import{k as Pe,u as Re}from"./vendor-hooks-zCCbpt45.js";import{r as m}from"./vendor-react-x2lQvn4m.js";import{D as G,C as Q,P as ee}from"./react-beautiful-dnd.esm-Cjgywj65.js";import{S as F}from"./studio-CiSsKpFb.js";import"./vendor-utils-CtD44yV-.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-BndcJjQO.js";import"./raf-schd.esm-BZ5FB5HD.js";import"./index-CnZyhA37.js";var I={},te;function Ee(){if(te)return I;te=1,Object.defineProperty(I,"__esModule",{value:!0}),I.getVideoId=b,I.getEmbedUrl=c,I.getVideoCoverUrl=P,I.getVideoCheckUrl=y,I.getYoutubeId=r,I.getVimeoId=a,I.isVideoUrl=w;function r(s){const t=s.trim();return t.includes("youtu.be/")?t.split("youtu.be/")[1]?.split("?")[0]:t.includes("/embed/")?t.split("/embed/")[1]?.split("?")[0]:t.includes("youtube.com/watch")?new URL(t).searchParams.get("v"):t.includes("youtube.com/shorts/")?t.split("/shorts/")[1]?.split("?")[0]:""}function a(s){const t=s.trim();return t.includes("/embed/")?t.split("/embed/")[1]?.split("?")[0]:t.includes("vimeo.com/video/")?t.split("/video/")[1]?.split("?")[0]:t.includes("vimeo.com/channels/")?t.split("/channels/")[1]?.split("/")[1]?.split("?")[0]:t.includes("vimeo.com/groups/")?t.split("/groups/")[1]?.split("/")[1]?.split("?")[0]:t.includes("vimeo.com/")?t.split("vimeo.com/")[1]?.split("?")[0]:""}const p={};function b(s){const t=s.trim();return!t||!/^https?:\/\/.+\..+/.test(t)?[]:(p[t]||(p[t]=(()=>{const u=new URL(t);return u.host.includes("youtube.com")||u.host.includes("youtu.be")?[r(t),"youtube"]:u.host.includes("vimeo.com")?[a(t),"vimeo"]:[]})()),p[t])}const n={};function c(s,{modestbranding:t=1,controls:u=0,autoplay:g=0}={}){const j=s.trim();if(!j)return"";if(n[j]!==void 0)return n[j];const[O,l]=b(j);return l==="youtube"?n[j]=`https://www.youtube.com/embed/${O}?modestbranding=${t}&controls=${u}&autoplay=${g}`:l==="vimeo"?n[j]=`https://player.vimeo.com/video/${O}?autoplay=${g}`:n[j]="",n[j]}const d={};function P(s){const t=s.trim();if(!t)return"";if(d[t]!==void 0)return d[t];const[u,g]=b(t);return g==="youtube"?d[t]=`https://img.youtube.com/vi/${u}/mqdefault.jpg`:g==="vimeo"?d[t]=`https://i.vimeocdn.com/${u}/1000x563`:d[t]="",d[t]}function y(s){const t=s.trim();if(!t)return"";const[u,g]=b(t);return g==="youtube"?`https://www.youtube.com/oembed?url=https://www.youtube.com/watch?v=${u}&format=json`:g==="vimeo"?`https://vimeo.com/api/oembed.json?url=https://vimeo.com/${u}`:""}function w(s){const t=s.trim();return b(t).length>0}return I}var q=Ee();const re=m.lazy(()=>be(()=>import("./index-BuCfItTx.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13])).then(r=>({default:r.Uploader}))),Oe=`${D.WELLKNOWN_SERVICE_PATH_PREFIX}/api/studio/logo/upload`,Ve=`${D.WELLKNOWN_SERVICE_PATH_PREFIX}/api/studio/screenshots/upload`,Le=`${D.WELLKNOWN_SERVICE_PATH_PREFIX}/api/studio/logo`,_=`${D.WELLKNOWN_SERVICE_PATH_PREFIX}/api/studio/screenshots`,De=`${D.WELLKNOWN_SERVICE_PATH_PREFIX}/api/studio/videos`,oe=5,ie=3;function Xe(){const{t:r,locale:a}=fe(),[p,b]=m.useState(!1),[n,c]=m.useState(!1),[d,P]=m.useState([]),[y,w]=m.useState([]),[s,t]=m.useState(""),[u,g]=m.useState(""),[j,O]=m.useState(Date.now()),l=Pe(async()=>{const i=await(await fetch(_)).json();return P(i.screenshots||[]),w(i.videos?.filter(h=>!!h)||[]),i}),f=m.useRef(null),C=m.useRef(null);if(l.loading&&!l.data)return e.jsx(F,{children:e.jsx(N,{size:40})});if(l.error)return e.jsx(F,{children:e.jsx(U,{direction:"column",spacing:1,sx:{mb:3},children:e.jsx(E,{sx:{color:"error.main",fontWeight:"bold"},children:l.error.message})})});const T=async o=>{const i=o.filter(h=>!!h);w(i),await fetch(De,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({videos:i})})},le=async o=>{const i=Array.from(y),[h]=i.splice(o.source.index,1);i.splice(o.destination.index,0,h),await T(i)},ce=async o=>{const i=Array.from(d),[h]=i.splice(o.source.index,1);i.splice(o.destination.index,0,h),P(i),await fetch(`${_}/reorder`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({screenshots:i})})},H=async o=>{o.destination&&(o.source.droppableId==="screenshots"?await ce(o):o.source.droppableId==="videos"&&await le(o),l.runAsync())},B=o=>{g(o.trim()),c(!0)},K=async(o,i="")=>{let h=[];i?h=o?y.map(v=>v===i?o.trim():v):y.filter(v=>v!==i):o&&(h=[...y,o.trim()]),g(""),c(!1),(o||i)&&await T(h),l.runAsync()},de=o=>{b(!0),t(o)},M=()=>{b(!1),t("")};function ue(){const o=[{label:r("studio.type"),value:"png, jpg, webp, svg"},{label:r("studio.ratio"),value:"256x256"},{label:r("studio.size"),value:"<500KB"}],i=[{label:r("studio.tip"),value:r("studio.change")}];return e.jsx($,{title:r("common.logo"),rules:o,tips:i,children:e.jsx(x,{sx:{flex:1,cursor:"pointer"},children:e.jsx(je,{variant:"square",sx:{width:128,height:128},alt:"Blocklet Logo",src:`${Le}?t=${j}`,onClick:()=>f.current?.open()})})})}function pe(){const o=[{label:r("studio.ratio"),value:"16 / 9"},{label:r("studio.count"),value:`1~${oe}`},{label:r("studio.size"),value:"<5MB"}],i=[{label:r("studio.tip"),value:r("studio.orderTipLong")}];return e.jsx($,{title:r("common.screenshot"),tips:i,rules:o,children:e.jsx(G,{onDragEnd:H,children:e.jsx(Q,{droppableId:"screenshots",direction:"horizontal",children:(v,V)=>e.jsxs(x,{ref:v.innerRef,...v.droppableProps,sx:{display:"flex",alignItems:"center",flex:1,mt:1,flexWrap:"wrap",minHeight:225,background:V.isDraggingOver?"#f5f5f5":"transparent",transition:"background-color 0.2s ease",border:V.isDraggingOver?"2px dashed #999":"none",borderRadius:"4px"},children:[d.map((S,z)=>e.jsx(ee,{draggableId:S,index:z,children:(R,L)=>{const X=`${_}/${S}`;return e.jsxs(x,{ref:R.innerRef,...R.draggableProps,...R.dragHandleProps,className:"image-wrapper",sx:{transform:L.isDragging?"scale(1.05)":"none",boxShadow:L.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:X,onClick:()=>de(S),style:{cursor:"pointer"}}),e.jsx(J,{title:r("studio.deleteTooltip"),children:e.jsx(A,{className:"action",style:{top:10,color:"white",background:"red"},onClick:async()=>{await fetch(X,{method:"DELETE"}),l.runAsync()},children:e.jsx(Y,{})})})]})}},S)),v.placeholder,d.length<oe&&h()]})})})});function h(){return e.jsx(x,{onClick:()=>C.current?.open(),sx:{display:"flex",justifyContent:"center",alignItems:"center",mb:2,width:400,height:225,fontSize:40,background:"#eee",cursor:"pointer",color:"#999"},children:"+"})}}function he(){const o=[{label:r("studio.count"),value:`1~${ie}`},{label:r("studio.videoType"),value:e.jsxs(e.Fragment,{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"})]})}],i=[{label:`${r("studio.tip")}`,value:r("studio.videoTipLong")}];return e.jsxs($,{title:r("studio.video"),tips:i,rules:o,children:[e.jsx(G,{onDragEnd:H,children:e.jsx(Q,{droppableId:"videos",direction:"horizontal",children:(v,V)=>e.jsxs(x,{ref:v.innerRef,...v.droppableProps,sx:{display:"flex",alignItems:"center",flex:1,mt:1,flexWrap:"wrap",minHeight:225,background:V.isDraggingOver?"#f5f5f5":"transparent",transition:"background-color 0.2s ease",border:V.isDraggingOver?"2px dashed #999":"none",borderRadius:"4px"},children:[y.map((S,z)=>e.jsx(ee,{draggableId:S,index:z,children:(R,L)=>e.jsxs(x,{ref:R.innerRef,...R.draggableProps,...R.dragHandleProps,className:"image-wrapper",sx:{transform:L.isDragging?"scale(1.05)":"none",boxShadow:L.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:"videos",src:q.getVideoCoverUrl(S),onClick:()=>B(S),style:{cursor:"pointer"}}),e.jsx(x,{sx:{position:"absolute",cursor:"pointer",fontSize:"3rem"},onClick:()=>B(S),children:e.jsx(ae,{})}),e.jsx(J,{title:r("studio.deleteTooltip"),children:e.jsx(A,{className:"action",style:{top:10,color:"white",background:"red"},onClick:()=>K(null,S),children:e.jsx(Y,{})})})]})},S)),v.placeholder,y.length<ie&&h()]})})}),n&&e.jsx(ne,{t:r,handleOperateVideo:K,defaultUrl:u,videos:y})]});function h(){return e.jsx(x,{onClick:()=>c(!0),sx:{display:"flex",justifyContent:"center",alignItems:"center",mb:2,width:400,height:225,fontSize:40,background:"#eee",cursor:"pointer",color:"#999"},children:"+"})}}function me(){return e.jsx(se,{open:p,onClose:M,maxWidth:"xl",slotProps:{paper:{style:{backgroundColor:"transparent",boxShadow:"none"}}},children:e.jsx("img",{src:`${_}/${s}`,alt:"Screenshot Full",style:{maxWidth:"90vw",maxHeight:"90vh",objectFit:"contain"},onClick:M})})}function xe(){return e.jsxs(m.Suspense,{fallback:e.jsx(N,{size:40}),children:[e.jsx(re,{ref:f,locale:a,popup:!0,onUploadFinish:()=>{f.current?.close(),O(Date.now()),l.runAsync()},plugins:["ImageEditor"],installerProps:{disabled:!0},apiPathProps:{uploader:Oe,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"),e.jsx(re,{ref:C,locale:a,popup:!0,onUploadFinish:()=>{C.current?.close(),l.runAsync()},installerProps:{disabled:!0},plugins:["ImageEditor"],apiPathProps:{uploader:Ve,disableMediaKitPrefix:!0,disableMediaKitStatus:!0},coreProps:{restrictions:{allowedFileTypes:["image/*","image/svg+xml"],maxFileSize:1024*1024*5,maxNumberOfFiles:5-d.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")]})}const ge=`https://www.arcblock.io/docs/blocklet-store/${a}/supplying-images`;return e.jsx(F,{children:e.jsxs(Te,{children:[e.jsxs(U,{direction:"column",spacing:1,sx:{mb:3},children:[e.jsx(E,{variant:"h5",sx:{fontWeight:"bold"},children:r("studio.title",{title:l.data?.title})}),e.jsxs(E,{variant:"body2",sx:{color:"text.secondary"},children:[r("studio.description")," ",e.jsx("a",{href:ge,target:"_blank",rel:"noreferrer",children:r("studio.documentation")})]})]}),ue(),pe(),he(),me(),xe()]})})}function $({title:r,rules:a,tips:p,children:b}){return e.jsxs(x,{sx:{display:"flex",flexDirection:"column",mb:4},children:[e.jsxs(U,{direction:"column",spacing:1,sx:{mb:2},children:[e.jsx(E,{variant:"h6",sx:{fontWeight:"bold"},children:r}),e.jsx(U,{direction:"row",spacing:2,sx:{fontSize:"13px",opacity:.8},children:a.map(c=>n(c.label,c.value))}),p.map(c=>e.jsx(x,{sx:{fontSize:"13px",opacity:.8},children:n(c.label,c.value)}))]}),b]});function n(c,d){return e.jsxs(x,{component:"span",children:[e.jsxs(x,{component:"span",sx:{color:"#555",mr:.5},children:[c,":"]}),e.jsx(x,{component:"span",sx:{color:"#007ec6"},children:d})]})}}$.propTypes={title:k.string.isRequired,rules:k.array.isRequired,tips:k.array.isRequired,children:k.node.isRequired};function ne({handleOperateVideo:r,t:a,defaultUrl:p="",videos:b}){const[n,c]=m.useState(p),[d,P]=m.useState(!1),[y,w]=m.useState(!1),s=m.useRef(n),t=n!==p&&b.includes(n),u=!n&&p,g=!t&&(n&&n!==s.current||d),j=!!navigator.clipboard?.readText,{run:O}=Re(l,{wait:500,leading:!0});return e.jsxs(se,{open:!0,fullWidth:!0,maxWidth:"sm",children:[e.jsx(ye,{children:a(p?"studio.videoDialogEditTitle":"studio.videoDialogTitle")}),e.jsxs(we,{children:[e.jsx(Ce,{fullWidth:!0,value:n,onChange:f=>{const C=f.target.value.trim();c(C),C?O(C):w(!1)},placeholder:a("studio.videoInputLabel"),endAdornment:n?e.jsx(Z,{position:"end",children:e.jsx(A,{onClick:()=>{c(""),l("")},children:e.jsx(Se,{})})}):j&&e.jsx(Z,{position:"end",children:e.jsx(A,{onClick:async()=>{try{const f=(await navigator.clipboard.readText()||"").trim();c(f),l(f)}catch(f){console.error(f)}},children:e.jsx(Ie,{})})})}),e.jsxs(x,{sx:{mb:2,mt:.5},children:[t&&e.jsx(E,{variant:"body2",color:"error",children:a("studio.duplicateVideo")}),!t&&y&&e.jsx(E,{variant:"body2",color:"error",children:a("studio.videoDialogNoSrc")})]}),s.current?e.jsx("iframe",{width:"100%",height:"315",title:`video-${s.current}`,src:q.getEmbedUrl(s.current),allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",allowFullScreen:!0,border:"1px solid #eee"}):e.jsx(x,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:315,width:"100%",border:"1px solid #eee"},children:d?e.jsx(N,{size:40}):e.jsx(E,{variant:"h5",sx:{color:"text.secondary"},children:e.jsx(ae,{})})})]}),e.jsxs(ke,{children:[e.jsx(W,{onClick:()=>r(),children:a("studio.cancel")}),u&&e.jsx(W,{variant:"contained",color:"error",onClick:()=>r(null,p),children:a("studio.delete")}),g&&e.jsx(W,{variant:"contained",onClick:()=>l(n),disabled:!n||d,children:a("studio.preview")}),!u&&!g&&e.jsx(W,{variant:"contained",onClick:()=>r(s.current),disabled:!s.current||p===s.current||t,children:a("studio.confirm")})]})]});function l(f){s.current="";const C=q.getVideoCheckUrl(f);w(f?!C:!1),C&&(P(!0),fetch(C).then(T=>{T.ok?(s.current=f,w(!1)):w(!0)}).catch(()=>{w(!0)}).finally(()=>P(!1)))}}ne.propTypes={handleOperateVideo:k.func.isRequired,t:k.func.isRequired,defaultUrl:k.string,videos:k.array.isRequired};function ae(){return e.jsxs("svg",{viewBox:"0 0 56 56",fill:"none",xmlns:"http://www.w3.org/2000/svg",height:48,width:48,children:[e.jsx("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M28 56C43.464 56 56 43.464 56 28C56 12.536 43.464 0 28 0C12.536 0 0 12.536 0 28C0 43.464 12.536 56 28 56Z",fill:"black","fill-opacity":"0.54"}),e.jsx("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M39.6667 28L21 17.5V38.5L39.6667 28Z",fill:"white"})]})}const Te=ve.div`
|
|
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{T as fe,_ as be}from"./vendor-ux-TkkDR0Gn.js";import{j as e,b1 as U,T as E,ak as x,b4 as je,am as J,I as A,bR as Y,a1 as se,at as ve,bB as ye,a3 as we,bv as Ce,H as Z,aJ as Se,bS as Ie,W as ke,V as W,$ as k}from"./vendor-mui-core-p6jGoroc.js";import{c as D}from"./index-CDq77s86.js";import{E as N}from"./empty-spinner-CpvmEmwT.js";import{k as Pe,u as Re}from"./vendor-hooks-zCCbpt45.js";import{r as m}from"./vendor-react-x2lQvn4m.js";import{D as G,C as Q,P as ee}from"./react-beautiful-dnd.esm-Cjgywj65.js";import{S as F}from"./studio-BoYrF6Kl.js";import"./vendor-utils-CtD44yV-.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-BndcJjQO.js";import"./raf-schd.esm-BZ5FB5HD.js";import"./index-glbEl-Pn.js";var I={},te;function Ee(){if(te)return I;te=1,Object.defineProperty(I,"__esModule",{value:!0}),I.getVideoId=b,I.getEmbedUrl=c,I.getVideoCoverUrl=P,I.getVideoCheckUrl=y,I.getYoutubeId=r,I.getVimeoId=a,I.isVideoUrl=w;function r(s){const t=s.trim();return t.includes("youtu.be/")?t.split("youtu.be/")[1]?.split("?")[0]:t.includes("/embed/")?t.split("/embed/")[1]?.split("?")[0]:t.includes("youtube.com/watch")?new URL(t).searchParams.get("v"):t.includes("youtube.com/shorts/")?t.split("/shorts/")[1]?.split("?")[0]:""}function a(s){const t=s.trim();return t.includes("/embed/")?t.split("/embed/")[1]?.split("?")[0]:t.includes("vimeo.com/video/")?t.split("/video/")[1]?.split("?")[0]:t.includes("vimeo.com/channels/")?t.split("/channels/")[1]?.split("/")[1]?.split("?")[0]:t.includes("vimeo.com/groups/")?t.split("/groups/")[1]?.split("/")[1]?.split("?")[0]:t.includes("vimeo.com/")?t.split("vimeo.com/")[1]?.split("?")[0]:""}const p={};function b(s){const t=s.trim();return!t||!/^https?:\/\/.+\..+/.test(t)?[]:(p[t]||(p[t]=(()=>{const u=new URL(t);return u.host.includes("youtube.com")||u.host.includes("youtu.be")?[r(t),"youtube"]:u.host.includes("vimeo.com")?[a(t),"vimeo"]:[]})()),p[t])}const n={};function c(s,{modestbranding:t=1,controls:u=0,autoplay:g=0}={}){const j=s.trim();if(!j)return"";if(n[j]!==void 0)return n[j];const[O,l]=b(j);return l==="youtube"?n[j]=`https://www.youtube.com/embed/${O}?modestbranding=${t}&controls=${u}&autoplay=${g}`:l==="vimeo"?n[j]=`https://player.vimeo.com/video/${O}?autoplay=${g}`:n[j]="",n[j]}const d={};function P(s){const t=s.trim();if(!t)return"";if(d[t]!==void 0)return d[t];const[u,g]=b(t);return g==="youtube"?d[t]=`https://img.youtube.com/vi/${u}/mqdefault.jpg`:g==="vimeo"?d[t]=`https://i.vimeocdn.com/${u}/1000x563`:d[t]="",d[t]}function y(s){const t=s.trim();if(!t)return"";const[u,g]=b(t);return g==="youtube"?`https://www.youtube.com/oembed?url=https://www.youtube.com/watch?v=${u}&format=json`:g==="vimeo"?`https://vimeo.com/api/oembed.json?url=https://vimeo.com/${u}`:""}function w(s){const t=s.trim();return b(t).length>0}return I}var q=Ee();const re=m.lazy(()=>be(()=>import("./index-T7E5JhUh.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13])).then(r=>({default:r.Uploader}))),Oe=`${D.WELLKNOWN_SERVICE_PATH_PREFIX}/api/studio/logo/upload`,Ve=`${D.WELLKNOWN_SERVICE_PATH_PREFIX}/api/studio/screenshots/upload`,Le=`${D.WELLKNOWN_SERVICE_PATH_PREFIX}/api/studio/logo`,_=`${D.WELLKNOWN_SERVICE_PATH_PREFIX}/api/studio/screenshots`,De=`${D.WELLKNOWN_SERVICE_PATH_PREFIX}/api/studio/videos`,oe=5,ie=3;function Xe(){const{t:r,locale:a}=fe(),[p,b]=m.useState(!1),[n,c]=m.useState(!1),[d,P]=m.useState([]),[y,w]=m.useState([]),[s,t]=m.useState(""),[u,g]=m.useState(""),[j,O]=m.useState(Date.now()),l=Pe(async()=>{const i=await(await fetch(_)).json();return P(i.screenshots||[]),w(i.videos?.filter(h=>!!h)||[]),i}),f=m.useRef(null),C=m.useRef(null);if(l.loading&&!l.data)return e.jsx(F,{children:e.jsx(N,{size:40})});if(l.error)return e.jsx(F,{children:e.jsx(U,{direction:"column",spacing:1,sx:{mb:3},children:e.jsx(E,{sx:{color:"error.main",fontWeight:"bold"},children:l.error.message})})});const T=async o=>{const i=o.filter(h=>!!h);w(i),await fetch(De,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({videos:i})})},le=async o=>{const i=Array.from(y),[h]=i.splice(o.source.index,1);i.splice(o.destination.index,0,h),await T(i)},ce=async o=>{const i=Array.from(d),[h]=i.splice(o.source.index,1);i.splice(o.destination.index,0,h),P(i),await fetch(`${_}/reorder`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({screenshots:i})})},H=async o=>{o.destination&&(o.source.droppableId==="screenshots"?await ce(o):o.source.droppableId==="videos"&&await le(o),l.runAsync())},B=o=>{g(o.trim()),c(!0)},K=async(o,i="")=>{let h=[];i?h=o?y.map(v=>v===i?o.trim():v):y.filter(v=>v!==i):o&&(h=[...y,o.trim()]),g(""),c(!1),(o||i)&&await T(h),l.runAsync()},de=o=>{b(!0),t(o)},M=()=>{b(!1),t("")};function ue(){const o=[{label:r("studio.type"),value:"png, jpg, webp, svg"},{label:r("studio.ratio"),value:"256x256"},{label:r("studio.size"),value:"<500KB"}],i=[{label:r("studio.tip"),value:r("studio.change")}];return e.jsx($,{title:r("common.logo"),rules:o,tips:i,children:e.jsx(x,{sx:{flex:1,cursor:"pointer"},children:e.jsx(je,{variant:"square",sx:{width:128,height:128},alt:"Blocklet Logo",src:`${Le}?t=${j}`,onClick:()=>f.current?.open()})})})}function pe(){const o=[{label:r("studio.ratio"),value:"16 / 9"},{label:r("studio.count"),value:`1~${oe}`},{label:r("studio.size"),value:"<5MB"}],i=[{label:r("studio.tip"),value:r("studio.orderTipLong")}];return e.jsx($,{title:r("common.screenshot"),tips:i,rules:o,children:e.jsx(G,{onDragEnd:H,children:e.jsx(Q,{droppableId:"screenshots",direction:"horizontal",children:(v,V)=>e.jsxs(x,{ref:v.innerRef,...v.droppableProps,sx:{display:"flex",alignItems:"center",flex:1,mt:1,flexWrap:"wrap",minHeight:225,background:V.isDraggingOver?"#f5f5f5":"transparent",transition:"background-color 0.2s ease",border:V.isDraggingOver?"2px dashed #999":"none",borderRadius:"4px"},children:[d.map((S,z)=>e.jsx(ee,{draggableId:S,index:z,children:(R,L)=>{const X=`${_}/${S}`;return e.jsxs(x,{ref:R.innerRef,...R.draggableProps,...R.dragHandleProps,className:"image-wrapper",sx:{transform:L.isDragging?"scale(1.05)":"none",boxShadow:L.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:X,onClick:()=>de(S),style:{cursor:"pointer"}}),e.jsx(J,{title:r("studio.deleteTooltip"),children:e.jsx(A,{className:"action",style:{top:10,color:"white",background:"red"},onClick:async()=>{await fetch(X,{method:"DELETE"}),l.runAsync()},children:e.jsx(Y,{})})})]})}},S)),v.placeholder,d.length<oe&&h()]})})})});function h(){return e.jsx(x,{onClick:()=>C.current?.open(),sx:{display:"flex",justifyContent:"center",alignItems:"center",mb:2,width:400,height:225,fontSize:40,background:"#eee",cursor:"pointer",color:"#999"},children:"+"})}}function he(){const o=[{label:r("studio.count"),value:`1~${ie}`},{label:r("studio.videoType"),value:e.jsxs(e.Fragment,{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"})]})}],i=[{label:`${r("studio.tip")}`,value:r("studio.videoTipLong")}];return e.jsxs($,{title:r("studio.video"),tips:i,rules:o,children:[e.jsx(G,{onDragEnd:H,children:e.jsx(Q,{droppableId:"videos",direction:"horizontal",children:(v,V)=>e.jsxs(x,{ref:v.innerRef,...v.droppableProps,sx:{display:"flex",alignItems:"center",flex:1,mt:1,flexWrap:"wrap",minHeight:225,background:V.isDraggingOver?"#f5f5f5":"transparent",transition:"background-color 0.2s ease",border:V.isDraggingOver?"2px dashed #999":"none",borderRadius:"4px"},children:[y.map((S,z)=>e.jsx(ee,{draggableId:S,index:z,children:(R,L)=>e.jsxs(x,{ref:R.innerRef,...R.draggableProps,...R.dragHandleProps,className:"image-wrapper",sx:{transform:L.isDragging?"scale(1.05)":"none",boxShadow:L.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:"videos",src:q.getVideoCoverUrl(S),onClick:()=>B(S),style:{cursor:"pointer"}}),e.jsx(x,{sx:{position:"absolute",cursor:"pointer",fontSize:"3rem"},onClick:()=>B(S),children:e.jsx(ae,{})}),e.jsx(J,{title:r("studio.deleteTooltip"),children:e.jsx(A,{className:"action",style:{top:10,color:"white",background:"red"},onClick:()=>K(null,S),children:e.jsx(Y,{})})})]})},S)),v.placeholder,y.length<ie&&h()]})})}),n&&e.jsx(ne,{t:r,handleOperateVideo:K,defaultUrl:u,videos:y})]});function h(){return e.jsx(x,{onClick:()=>c(!0),sx:{display:"flex",justifyContent:"center",alignItems:"center",mb:2,width:400,height:225,fontSize:40,background:"#eee",cursor:"pointer",color:"#999"},children:"+"})}}function me(){return e.jsx(se,{open:p,onClose:M,maxWidth:"xl",slotProps:{paper:{style:{backgroundColor:"transparent",boxShadow:"none"}}},children:e.jsx("img",{src:`${_}/${s}`,alt:"Screenshot Full",style:{maxWidth:"90vw",maxHeight:"90vh",objectFit:"contain"},onClick:M})})}function xe(){return e.jsxs(m.Suspense,{fallback:e.jsx(N,{size:40}),children:[e.jsx(re,{ref:f,locale:a,popup:!0,onUploadFinish:()=>{f.current?.close(),O(Date.now()),l.runAsync()},plugins:["ImageEditor"],installerProps:{disabled:!0},apiPathProps:{uploader:Oe,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"),e.jsx(re,{ref:C,locale:a,popup:!0,onUploadFinish:()=>{C.current?.close(),l.runAsync()},installerProps:{disabled:!0},plugins:["ImageEditor"],apiPathProps:{uploader:Ve,disableMediaKitPrefix:!0,disableMediaKitStatus:!0},coreProps:{restrictions:{allowedFileTypes:["image/*","image/svg+xml"],maxFileSize:1024*1024*5,maxNumberOfFiles:5-d.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")]})}const ge=`https://www.arcblock.io/docs/blocklet-store/${a}/supplying-images`;return e.jsx(F,{children:e.jsxs(Te,{children:[e.jsxs(U,{direction:"column",spacing:1,sx:{mb:3},children:[e.jsx(E,{variant:"h5",sx:{fontWeight:"bold"},children:r("studio.title",{title:l.data?.title})}),e.jsxs(E,{variant:"body2",sx:{color:"text.secondary"},children:[r("studio.description")," ",e.jsx("a",{href:ge,target:"_blank",rel:"noreferrer",children:r("studio.documentation")})]})]}),ue(),pe(),he(),me(),xe()]})})}function $({title:r,rules:a,tips:p,children:b}){return e.jsxs(x,{sx:{display:"flex",flexDirection:"column",mb:4},children:[e.jsxs(U,{direction:"column",spacing:1,sx:{mb:2},children:[e.jsx(E,{variant:"h6",sx:{fontWeight:"bold"},children:r}),e.jsx(U,{direction:"row",spacing:2,sx:{fontSize:"13px",opacity:.8},children:a.map(c=>n(c.label,c.value))}),p.map(c=>e.jsx(x,{sx:{fontSize:"13px",opacity:.8},children:n(c.label,c.value)}))]}),b]});function n(c,d){return e.jsxs(x,{component:"span",children:[e.jsxs(x,{component:"span",sx:{color:"#555",mr:.5},children:[c,":"]}),e.jsx(x,{component:"span",sx:{color:"#007ec6"},children:d})]})}}$.propTypes={title:k.string.isRequired,rules:k.array.isRequired,tips:k.array.isRequired,children:k.node.isRequired};function ne({handleOperateVideo:r,t:a,defaultUrl:p="",videos:b}){const[n,c]=m.useState(p),[d,P]=m.useState(!1),[y,w]=m.useState(!1),s=m.useRef(n),t=n!==p&&b.includes(n),u=!n&&p,g=!t&&(n&&n!==s.current||d),j=!!navigator.clipboard?.readText,{run:O}=Re(l,{wait:500,leading:!0});return e.jsxs(se,{open:!0,fullWidth:!0,maxWidth:"sm",children:[e.jsx(ye,{children:a(p?"studio.videoDialogEditTitle":"studio.videoDialogTitle")}),e.jsxs(we,{children:[e.jsx(Ce,{fullWidth:!0,value:n,onChange:f=>{const C=f.target.value.trim();c(C),C?O(C):w(!1)},placeholder:a("studio.videoInputLabel"),endAdornment:n?e.jsx(Z,{position:"end",children:e.jsx(A,{onClick:()=>{c(""),l("")},children:e.jsx(Se,{})})}):j&&e.jsx(Z,{position:"end",children:e.jsx(A,{onClick:async()=>{try{const f=(await navigator.clipboard.readText()||"").trim();c(f),l(f)}catch(f){console.error(f)}},children:e.jsx(Ie,{})})})}),e.jsxs(x,{sx:{mb:2,mt:.5},children:[t&&e.jsx(E,{variant:"body2",color:"error",children:a("studio.duplicateVideo")}),!t&&y&&e.jsx(E,{variant:"body2",color:"error",children:a("studio.videoDialogNoSrc")})]}),s.current?e.jsx("iframe",{width:"100%",height:"315",title:`video-${s.current}`,src:q.getEmbedUrl(s.current),allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",allowFullScreen:!0,border:"1px solid #eee"}):e.jsx(x,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:315,width:"100%",border:"1px solid #eee"},children:d?e.jsx(N,{size:40}):e.jsx(E,{variant:"h5",sx:{color:"text.secondary"},children:e.jsx(ae,{})})})]}),e.jsxs(ke,{children:[e.jsx(W,{onClick:()=>r(),children:a("studio.cancel")}),u&&e.jsx(W,{variant:"contained",color:"error",onClick:()=>r(null,p),children:a("studio.delete")}),g&&e.jsx(W,{variant:"contained",onClick:()=>l(n),disabled:!n||d,children:a("studio.preview")}),!u&&!g&&e.jsx(W,{variant:"contained",onClick:()=>r(s.current),disabled:!s.current||p===s.current||t,children:a("studio.confirm")})]})]});function l(f){s.current="";const C=q.getVideoCheckUrl(f);w(f?!C:!1),C&&(P(!0),fetch(C).then(T=>{T.ok?(s.current=f,w(!1)):w(!0)}).catch(()=>{w(!0)}).finally(()=>P(!1)))}}ne.propTypes={handleOperateVideo:k.func.isRequired,t:k.func.isRequired,defaultUrl:k.string,videos:k.array.isRequired};function ae(){return e.jsxs("svg",{viewBox:"0 0 56 56",fill:"none",xmlns:"http://www.w3.org/2000/svg",height:48,width:48,children:[e.jsx("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M28 56C43.464 56 56 43.464 56 28C56 12.536 43.464 0 28 0C12.536 0 0 12.536 0 28C0 43.464 12.536 56 28 56Z",fill:"black","fill-opacity":"0.54"}),e.jsx("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M39.6667 28L21 17.5V38.5L39.6667 28Z",fill:"white"})]})}const Te=ve.div`
|
|
3
3
|
margin-top: 24px;
|
|
4
4
|
.image-wrapper {
|
|
5
5
|
margin-bottom: 16px;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as J,r as x}from"./vendor-react-x2lQvn4m.js";import{j as e,I as D,bd as j1,V as T,c0 as y1,U as a1,S as Z1,ai as w1,v as b1,M as k1,$ as c,G as l1,ak as i,p as i1,bH as c1,aj as Y,b$ as L1,c1 as M1,at as G,Y as R1,F as S1,c2 as Q,b7 as E1,b4 as _1,ar as C1,T as C,a7 as I,b1 as B1}from"./vendor-mui-core-p6jGoroc.js";import{b as t1,G as O1,F as P1,e as H1,H as A1}from"./vendor-ux-TkkDR0Gn.js";import{l as V1}from"./vendor-hooks-zCCbpt45.js";import{_ as s1,ax as I1,ay as z1,M as L}from"./index-
|
|
1
|
+
import{a as J,r as x}from"./vendor-react-x2lQvn4m.js";import{j as e,I as D,bd as j1,V as T,c0 as y1,U as a1,S as Z1,ai as w1,v as b1,M as k1,$ as c,G as l1,ak as i,p as i1,bH as c1,aj as Y,b$ as L1,c1 as M1,at as G,Y as R1,F as S1,c2 as Q,b7 as E1,b4 as _1,ar as C1,T as C,a7 as I,b1 as B1}from"./vendor-mui-core-p6jGoroc.js";import{b as t1,G as O1,F as P1,e as H1,H as A1}from"./vendor-ux-TkkDR0Gn.js";import{l as V1}from"./vendor-hooks-zCCbpt45.js";import{_ as s1,ax as I1,ay as z1,M as L}from"./index-CDq77s86.js";import{s as F1}from"./sanitize-12ijS2UQ.js";import{F as r1,R as o1,L as H}from"./logo-uploader-CnbjQmUt.js";import{e as T1}from"./edit.svg-D-deOViK.js";import{w as h1}from"./permission-3PNyBKZ2.js";import{u as N1}from"./use-blocklet-logo-C7qZcidt.js";import{S as z}from"./section-iFIMehPS.js";import"./vendor-utils-CtD44yV-.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-BndcJjQO.js";import"./omit-C6lXG4Q2.js";import"./index-MGxe3V9B.js";import"./session-CvQ97dDY.js";function n1({triggers:a=[],onEnterEdit:s,disabled:p}){const h=J.useRef(null),[M,m]=J.useState(!1),u=f=>{m(!1),f()},l=()=>{m(f=>!f)},o=f=>{h.current&&h.current.contains(f.target)||m(!1)};return a.length===0?e.jsx(D,{"data-cy":"schema-form-item-edit",onClick:s,disabled:p,size:"large",children:e.jsx(T1,{})}):e.jsxs(e.Fragment,{children:[e.jsx(j1,{variant:"outlined",ref:h,"aria-label":"split button",children:e.jsx(T,{size:"large","aria-controls":M?"split-button-menu":void 0,"aria-expanded":M?"true":void 0,sx:{paddingLeft:"12px",paddingRight:"12px"},onClick:l,children:e.jsx(y1,{})})}),e.jsx(a1,{sx:{zIndex:9999},open:M,anchorEl:h.current,role:void 0,placement:"bottom-end",children:e.jsx(Z1,{children:e.jsx(w1,{onClickAway:o,children:e.jsx(b1,{id:"split-button-menu",autoFocusItem:!0,children:a.map(f=>e.jsx(k1,{onClick:()=>u(f.handler),children:f.title},f.key))})})})})]})}n1.propTypes={triggers:c.arrayOf(c.shape({key:c.string.isRequired,title:c.string.isRequired,handler:c.func.isRequired})),onEnterEdit:c.func.isRequired,disabled:c.bool.isRequired};const e1=(a,s,p)=>a===null&&s&&p?"******":a?s?"******":a:"",U1=L1`
|
|
2
2
|
0%, 100% {
|
|
3
3
|
transform: scale(1) translateX(0);
|
|
4
4
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as u,b4 as x,$ as e}from"./vendor-mui-core-p6jGoroc.js";import{$}from"./vendor-ux-TkkDR0Gn.js";import{C as m}from"./vendor-utils-CtD44yV-.js";import{_ as l,a9 as v,aa as j,c as y,ab as E,ac as P}from"./index-
|
|
1
|
+
import{j as u,b4 as x,$ as e}from"./vendor-mui-core-p6jGoroc.js";import{$}from"./vendor-ux-TkkDR0Gn.js";import{C as m}from"./vendor-utils-CtD44yV-.js";import{_ as l,a9 as v,aa as j,c as y,ab as E,ac as P}from"./index-CDq77s86.js";function R({blocklet:o,ancestors:d=[]}){const t=l(),{inService:s}=t,n=v(o?.status)||j(o?.status),r=`?v=${o?.meta?.version}${n?"~":""}`;let a=s?`${m(E,y.WELLKNOWN_SERVICE_PATH_PREFIX,"/blocklet/logo-bundle")}${r}`:m(t.imgPrefix,"blocklet.png");if(o.source==="registry"&&o.deployedFrom&&o.meta.logo)a=`${m(o.deployedFrom,P(o.meta.bundleDid,o.meta.logo))}${r}`;else{const g=window.env?.apiPrefix||"/",i=d.concat(o),p=s?i.slice(1):i;a=`${m(g,`/blocklet/logo-bundle${p.map(c=>`/${c.meta.did}`).join("")}`)}${r}`}return{logoUrl:a,inService:s}}function h({blocklet:o,style:d={},size:t=40,ancestors:s=[],...n}){const r=l(),{logoUrl:a,inService:g}=R({blocklet:o,ancestors:s}),{variant:i}=n,p=g?()=>{}:f=>{f.target.src=`${r.imgPrefix}/blocklet.png`};let c=u.jsx("img",{src:a,onError:p,alt:o.meta.name,style:{width:t}});return o.meta.logo||(c=u.jsx($,{did:o.meta.did||"",responsive:!0})),u.jsx(x,{variant:i||"square",style:Object.assign({backgroundColor:"transparent",width:t,height:t,borderRadius:10},d),...n,children:c})}h.propTypes={blocklet:e.object.isRequired,style:e.object,size:e.oneOfType([e.number,e.string]),ancestors:e.array};export{h as B};
|