@abtnode/blocklet-services 1.17.3 → 1.17.4-beta-20251201-225048-b1682a09

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.
Files changed (124) hide show
  1. package/dist/assets/{access-control-2f5ZUYvn.js → access-control-BpDf5eCc.js} +1 -1
  2. package/dist/assets/{add-component-core-C8wP5DXr.js → add-component-core-DZMleaf7.js} +1 -1
  3. package/dist/assets/{add-resource-D-X1I5_V.js → add-resource-fReirUEj.js} +1 -1
  4. package/dist/assets/{addon-DWBAL8PD.js → addon-CD2tT3Vk.js} +1 -1
  5. package/dist/assets/{advanced-l0XvYXrR.js → advanced-D_HYmeDL.js} +1 -1
  6. package/dist/assets/{aigne-CsKyE9Oj.js → aigne-DKzLdZPY.js} +1 -1
  7. package/dist/assets/{appearance-CDE_5zqq.js → appearance-DoI_K1yx.js} +1 -1
  8. package/dist/assets/{arrow-down.svg-C5rjQJG2.js → arrow-down.svg-mj2eIUoA.js} +1 -1
  9. package/dist/assets/{audit-logs-CvWoJqnE.js → audit-logs-CBeb46aa.js} +1 -1
  10. package/dist/assets/{authorize-CgqsMeVu.js → authorize-BQTDaD7S.js} +1 -1
  11. package/dist/assets/{bind-account-C_93rOKB.js → bind-account--wlCwoIh.js} +1 -1
  12. package/dist/assets/{branding-D-5p5wha.js → branding-Bs3FNZ79.js} +1 -1
  13. package/dist/assets/{branding-MYLazJOV.js → branding-CMNxsyrp.js} +1 -1
  14. package/dist/assets/{branding-C56V2vpD.js → branding-Sd6X0YqE.js} +1 -1
  15. package/dist/assets/{bundle-avatar-BdQv8P8t.js → bundle-avatar-DACPWlAj.js} +1 -1
  16. package/dist/assets/{complete-BSud_fLS.js → complete-BIrSCTBJ.js} +1 -1
  17. package/dist/assets/{component-Z_4kfVE0.js → component-BrH7uZv7.js} +2 -2
  18. package/dist/assets/{config-tFuMpr42.js → config-BbbJtsEK.js} +1 -1
  19. package/dist/assets/{config-QNXiPFng.js → config-BlvlFPnu.js} +1 -1
  20. package/dist/assets/config-C0IukdMa.js +57 -0
  21. package/dist/assets/{config-navigation-BdlyLYhE.js → config-navigation-CPqSm2b8.js} +2 -2
  22. package/dist/assets/{config-space-BSBup5aB.js → config-space-B6ikfnoY.js} +1 -1
  23. package/dist/assets/{confirm-DPD7yjeR.js → confirm-Dge1BR0a.js} +1 -1
  24. package/dist/assets/{connect-C51xT0zT.js → connect-DwfU2nBg.js} +1 -1
  25. package/dist/assets/{connect-DFCRlbN9.js → connect-DwftqrTP.js} +1 -1
  26. package/dist/assets/{connect-to-B-qzDPba.js → connect-to-D3Fxg-mH.js} +1 -1
  27. package/dist/assets/{dashboard-Cto_eSyJ.js → dashboard-BZMyxtap.js} +2 -2
  28. package/dist/assets/{delete-confirm-G3d9EUZU.js → delete-confirm-CaK42Rqi.js} +1 -1
  29. package/dist/assets/{domain-CJ3ZeLQs.js → domain-DZhOKUFR.js} +1 -1
  30. package/dist/assets/{domain-action-card-BAzAGOUR.js → domain-action-card-KBcfeUDt.js} +1 -1
  31. package/dist/assets/{domains-CbYSc-np.js → domains-Dr63r27w.js} +1 -1
  32. package/dist/assets/{email-BbooLxm_.js → email-mM-fSS-l.js} +1 -1
  33. package/dist/assets/engine-BCYKeHn7.js +1 -0
  34. package/dist/assets/{exchange-passport-B7UqzIxE.js → exchange-passport-CL0-QMoV.js} +1 -1
  35. package/dist/assets/{form-Ci18kVmF.js → form-BQvsWiOt.js} +1 -1
  36. package/dist/assets/{fuel-BE74WZ6j.js → fuel-BpMa6xEp.js} +1 -1
  37. package/dist/assets/{gen-access-key-s40ict9x.js → gen-access-key-BLtBtR5W.js} +1 -1
  38. package/dist/assets/{gen-simple-access-key-D8YVPusH.js → gen-simple-access-key-9tFWfYxA.js} +1 -1
  39. package/dist/assets/{get-safe-url-DT47R_1b.js → get-safe-url-CxrqaBih.js} +1 -1
  40. package/dist/assets/{home-C9ok8LuA.js → home-BG4Bn0-p.js} +1 -1
  41. package/dist/assets/{iframe-BoFxpqBT.js → iframe-BjsS1KQR.js} +1 -1
  42. package/dist/assets/{index-DbmL_qgW.js → index-5hr4oNRS.js} +3 -3
  43. package/dist/assets/{index-CionuFLd.js → index-88gdbkao.js} +1 -1
  44. package/dist/assets/{index-YApW_a5L.js → index-B00Da_zr.js} +1 -1
  45. package/dist/assets/{index-ByWjeUNp.js → index-B4Q4y_7n.js} +1 -1
  46. package/dist/assets/{index-CimoFUNL.js → index-B6-5SXSy.js} +1 -1
  47. package/dist/assets/{index-CCaP8G-5.js → index-B8mnhcds.js} +2 -2
  48. package/dist/assets/{index-DXYr8-bJ.js → index-B8uWH9ks.js} +1 -1
  49. package/dist/assets/{index-DA4iEV0M.js → index-BIlfbBZ2.js} +1 -1
  50. package/dist/assets/{index-tukXJbMk.js → index-BUomsang.js} +1 -1
  51. package/dist/assets/{index-CUHwnb5s.js → index-BVYUGxzR.js} +1 -1
  52. package/dist/assets/{index-ClpPXMAi.js → index-BmuOS9l2.js} +1 -1
  53. package/dist/assets/{index-CgnIkelt.js → index-BoeLorfn.js} +1 -1
  54. package/dist/assets/{index-CTzNs74h.js → index-BzCDxVOL.js} +1 -1
  55. package/dist/assets/{index-BpNkmzkz.js → index-C40tsw4I.js} +1 -1
  56. package/dist/assets/{index-CFLPfp6M.js → index-CNE3uN5c.js} +1 -1
  57. package/dist/assets/{index-h3JyhqqC.js → index-CgTWMV4T.js} +1 -1
  58. package/dist/assets/{index-DQB7DBpQ.js → index-CxJOg5jI.js} +1 -1
  59. package/dist/assets/{index-DrJnt_vf.js → index-Cy73v3o9.js} +1 -1
  60. package/dist/assets/{index-C0TbDTja.js → index-D6MFQa2J.js} +1 -1
  61. package/dist/assets/{index-BJz7bmlp.js → index-D9UpcFKi.js} +1 -1
  62. package/dist/assets/{index-DaIayPTI.js → index-DEDj0oVc.js} +1 -1
  63. package/dist/assets/{index-DtUiw_0b.js → index-KUb_kVWp.js} +1 -1
  64. package/dist/assets/{index-CpVl3QY6.js → index-V83VNrab.js} +1 -1
  65. package/dist/assets/{index-CMuQuCcn.js → index-h0Os_ox8.js} +1 -1
  66. package/dist/assets/{index-CN4lpn74.js → index-lFDZOk_k.js} +3 -3
  67. package/dist/assets/{index-CekShFJg.js → index-sfOXn4Gu.js} +1 -1
  68. package/dist/assets/{invitation-XkzkbIwS.js → invitation-LJOuA09f.js} +1 -1
  69. package/dist/assets/{invitations-Cy_dNcIE.js → invitations-DtmYY9Tr.js} +1 -1
  70. package/dist/assets/{invite-BSYvges4.js → invite-DrIYCYzj.js} +1 -1
  71. package/dist/assets/{isURL-DskT4RKm.js → isURL-fcz3vuMN.js} +1 -1
  72. package/dist/assets/{issue-passport-opYjcMCB.js → issue-passport-Dv9gH2LH.js} +1 -1
  73. package/dist/assets/{item-DToR6hlW.js → item-weuCOdTL.js} +1 -1
  74. package/dist/assets/{landing-page-DFIsLbb7.js → landing-page-Djj9jDve.js} +1 -1
  75. package/dist/assets/{layout-CkQwn0NR.js → layout-0zU7a-3v.js} +1 -1
  76. package/dist/assets/{list-D5UHzaOx.js → list-Co62gn7d.js} +1 -1
  77. package/dist/assets/{list-D4Gs036Z.js → list-DXe9E4ws.js} +1 -1
  78. package/dist/assets/{localization-DzNUtlVV.js → localization-CufkU3et.js} +1 -1
  79. package/dist/assets/{log-RL9u31-I.js → log-BCC7blv9.js} +1 -1
  80. package/dist/assets/{login-CqeIoGod.js → login-DlWL3WVr.js} +1 -1
  81. package/dist/assets/{login-oauth-callback-0Nu4mPXk.js → login-oauth-callback-CQFS2s22.js} +1 -1
  82. package/dist/assets/{logo-uploader-Cv5-KB8L.js → logo-uploader-Dz85eY-W.js} +1 -1
  83. package/dist/assets/{lost-passport-CoOQTlhO.js → lost-passport-pRlBbp2M.js} +1 -1
  84. package/dist/assets/{open-window-BHKfDlI-.js → open-window-X4W6wF0y.js} +1 -1
  85. package/dist/assets/{over-due-invoice-payment-MovV2cwi.js → over-due-invoice-payment-CvKa0suc.js} +1 -1
  86. package/dist/assets/{overview-CCLvrJi4.js → overview-d6xffU9N.js} +1 -1
  87. package/dist/assets/{passport-CqvORkfw.js → passport-DHiNUeVn.js} +1 -1
  88. package/dist/assets/{passport-item-BMa8rd85.js → passport-item-BkmVlAdr.js} +1 -1
  89. package/dist/assets/{permission-DLnMVuoy.js → permission-B3_OQqtH.js} +1 -1
  90. package/dist/assets/{preferences-CDvS8_ng.js → preferences-D321ZAU1.js} +1 -1
  91. package/dist/assets/{profile-embed-C8ofqlbV.js → profile-embed-Ba3F6nXm.js} +1 -1
  92. package/dist/assets/{publish-resource-CMoJF5DA.js → publish-resource-Aoo5xCZX.js} +1 -1
  93. package/dist/assets/{runtime-D2sDgwrj.js → runtime-xK-SJ1cq.js} +1 -1
  94. package/dist/assets/sdk-DAuiCSLy.js +1 -0
  95. package/dist/assets/{security-D7O7D2Dn.js → security-B3q0KDVH.js} +1 -1
  96. package/dist/assets/{session-DNlfWI2Z.js → session-DR7jqIW5.js} +1 -1
  97. package/dist/assets/{setup-CxJT_7C9.js → setup-CPrn9v2_.js} +1 -1
  98. package/dist/assets/{simple-select-BAtHv3cq.js → simple-select-SyYgbCc2.js} +1 -1
  99. package/dist/assets/{spaces-B9YyAxJd.js → spaces-C_pXJSzm.js} +1 -1
  100. package/dist/assets/{start-TaXS82Bg.js → start-BUxgx8Ah.js} +1 -1
  101. package/dist/assets/{starting-progress-B6ma-ZGa.js → starting-progress-BP_Sqg1X.js} +1 -1
  102. package/dist/assets/{status-DsksxwVa.js → status-CE6iXPs_.js} +1 -1
  103. package/dist/assets/{step-actions-DbAALRbw.js → step-actions-tRQyAl6A.js} +1 -1
  104. package/dist/assets/{studio-IkWmW2Xk.js → studio-bbXFMut7.js} +1 -1
  105. package/dist/assets/{team-BnNEVFdE.js → team-KWOyNaWn.js} +1 -1
  106. package/dist/assets/{traffic-BibrNphF.js → traffic-ChddnVTm.js} +1 -1
  107. package/dist/assets/{transfer-CPU5ZBFf.js → transfer-CcCi6t4X.js} +1 -1
  108. package/dist/assets/{unsubscribe-CBHokiq9.js → unsubscribe-Bp5VQCnR.js} +1 -1
  109. package/dist/assets/{use-app-logo-BWOYOuhG.js → use-app-logo-hGlkw2d_.js} +1 -1
  110. package/dist/assets/{user-center-DxoxMBFK.js → user-center-CXduwafJ.js} +2 -2
  111. package/dist/assets/{user-follower-CNxYFKVI.js → user-follower-CmGz7Inx.js} +1 -1
  112. package/dist/assets/{util-DWpY3O7e.js → util-D-cKMKUM.js} +1 -1
  113. package/dist/assets/{util-DzwOLYt5.js → util-MbDHkO8z.js} +1 -1
  114. package/dist/assets/{wait-connect-Crb0Z6pk.js → wait-connect-DDyEqw4h.js} +1 -1
  115. package/dist/assets/{wizard-GO-eYrph.js → wizard-B588KidT.js} +1 -1
  116. package/dist/assets/{wizard-components-B0p6B74G.js → wizard-components-DP7Z_TTm.js} +1 -1
  117. package/dist/assets/{wrap-locale-C_7Ff1OO.js → wrap-locale-CFMie_Pc.js} +1 -1
  118. package/dist/assets/{zh-kaABsCb2.js → zh-C_L8CY4f.js} +1 -1
  119. package/dist/index.html +1 -1
  120. package/dist/service-worker.js +1 -1
  121. package/package.json +23 -23
  122. package/dist/assets/config-YjT0ptkh.js +0 -57
  123. package/dist/assets/engine-7kGw4V-U.js +0 -1
  124. package/dist/assets/sdk-CiQg0Ndf.js +0 -1
@@ -1,5 +1,5 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=[window.__toCdnUrl("assets/vendor-ux-DYcPPYq2.css"),window.__toCdnUrl("assets/index-DrVXX4fX.css"),window.__toCdnUrl("assets/index-B5LvOF-F.css")])))=>i.map(i=>d[i]);
2
- import{r as k,i as It,j as rt,L as we,g as xo,k as qs,l as Ns,m as bt}from"./vendor-react-CUXIiAnY.js";import{J as Oe,j as e,ak as a,b4 as Et,W as n,am as xe,I as ce,dx as _s,dy as Ws,bb as go,cb as nt,dz as Os,a_ as zs,T as $,s as ko,cy as jo,dA as Bs,cP as Vs,Y as lt,at as ve,av as Us,dB as Ms,a5 as He,aX as it,bd as Pt,c7 as Fs,bh as Hs,b6 as Me,cX as Js,bi as et,Q as G,a6 as Se,bE as Xs,O as yo,K as wo,P as Lt,ai as vo,o as Co,M as be,a3 as Gs,bC as Ro,$ as So,bw as Ks,A as Xe,aJ as Ys,R as To,z as ne,b1 as Re,dC as Xt,bX as tt,dD as Do,V as Io,S as At,aP as Eo,bD as Zs,D as Po,cs as Qs,aQ as er,aR as tr,ct as or,cu as sr,bF as Lo,aq as rr,dE as nr,a1 as Ao,a0 as ot,bj as Gt,bP as lr,bQ as ir,dF as cr,dG as ar,bc as vt,y as dr,F as ur,bq as pr,br as ft}from"./vendor-mui-core-DHT36AZL.js";import{c as F,_ as ke,ac as De,v as hr,Y as me,bO as mr,Z as br,e as Kt,bP as fr,az as Yt,b8 as xr,bx as gr,bQ as kr,bR as jr,bS as yr}from"./index-CN4lpn74.js";import{V as X,a2 as $o,x as wr,n as Ae,Q as qo,z as No,P as vr,h as $t,H as W,q as qt,aK as Nt,U as ae,_ as _o,A as We,b as ct,j as Wo}from"./vendor-ux-sqP3hEhY.js";import{C as at}from"./confirm-DPD7yjeR.js";import{u as ze}from"./session-DNlfWI2Z.js";import{W as Ct}from"./did-address-CihvGtuj.js";import{E as Ge}from"./empty-spinner-2ylB84wv.js";import{B as _t}from"./bundle-avatar-BdQv8P8t.js";import{S as Te}from"./shorten-label-Cf--RqV-.js";import{L as Wt}from"./list-header-CA-QkwGq.js";import{K as Cr,C as ue,A as Ot,D as Oo,a0 as Rr}from"./vendor-utils-BSZ4yJws.js";import{C as zo}from"./click-to-copy-DZ_4RDjR.js";import{t as Zt}from"./question-mark-circle.svg-DK9nTUDZ.js";import{l as Sr,b as Tr}from"./vendor-hooks-fhL5FJET.js";import{u as Fe}from"./useSetState-cWrp7qoX.js";import{e as Dr}from"./engine-7kGw4V-U.js";import"./api-DIucIOLX.js";import{T as Ir,S as Er}from"./vendor-mui-x-B4OOX5Es.js";import{D as Qt,C as eo,P as to}from"./react-beautiful-dnd.esm--C1KYPc1.js";import{u as Bo,c as Pr,w as Lr,a as Ar,b as $r}from"./wait-connect-Crb0Z6pk.js";import{f as ge}from"./index-DBs9Ljax.js";import{c as qr,A as Vo,S as Nr,U as _r,r as Wr}from"./item-DToR6hlW.js";import{D as Or}from"./delete-confirm-G3d9EUZU.js";import{g as Uo}from"./get-safe-url-DT47R_1b.js";import{u as Le}from"./index-B9Igf2rm.js";import{M as zr}from"./index-CO3X6G_g.js";import{r as Br}from"./index-yGC4DbEU.js";import"./vendor-arcblock-3xKfH3F1.js";import"./lottie-web-4koyQiv_.js";import"./raf-schd.esm-JNUhxcps.js";function zt({did:t,projectId:o,title:s,logo:r,describe:l}){const i=`${`${F.WELLKNOWN_SERVICE_PATH_PREFIX}/api/project/${t}/${o}/logo/upload`}/${r}`,[d,u]=k.useState(!1),x=Oe(p=>p.breakpoints.down("md"));return e.jsxs(a,{sx:{display:"flex",flexDirection:"row",color:d?"primary.main":"grey.900",gap:1},onPointerEnter:()=>u(!0),onPointerLeave:()=>u(!1),children:[e.jsx(Et,{sx:{borderRadius:1},src:i}),e.jsxs(a,{children:[e.jsx(Te,{hiddenTip:!0,maxLength:"24",sx:{fontSize:"14px",fontWeight:"500",color:x?"primary.main":""},children:s||"/"}),e.jsx(Te,{hiddenTip:!0,maxLength:"58",sx:{fontSize:"12px",color:x||d?"primary.main":"grey.700"},children:l||"/"})]})]})}zt.propTypes={projectId:n.string.isRequired,did:n.string.isRequired,title:n.string.isRequired,logo:n.string.isRequired,describe:n.string.isRequired};function Mo({initUrl:t=null}){const o=It(),s=t?.searchParams.get("tenantScope")||"",{t:r,locale:l}=X(),{api:c}=ke(),{api:i}=ze(),[d,u]=k.useState(!0),{blocklet:x}=De(),[p,m]=k.useState(null),[f,b]=k.useState(!1),h=Oe(E=>E.breakpoints.down("xl")),j=Oe(E=>E.breakpoints.down("md")),{componentDid:v=""}=rt(),[g,C]=k.useState(null),D=`publish-${x.meta.did}`,R=$o(D),[y,T]=k.useState({searchText:R.searchText||"",pageSize:R.rowsPerPage||10,page:1}),O=()=>{c.getProjects({input:{did:x.meta.did,componentDid:v,tenantScope:s}}).then(E=>{const I=E?.projects||[];u(!1),C(I)}).catch(E=>{u(!1),W.error(E.message)})},N=()=>{o(`${F.UNOWNED_DID}/create/none/0.0.0`,{replace:!0})},z=E=>{m(E)},K=()=>{u(!1),b(!0)},P=()=>{b(!1),m(null)},A=E=>{W.error(E.message),b(!1),m(null)},w=E=>{if(!E?.deleted){W.error("Delete project failed");return}O(),b(!1),m(null)};k.useEffect(()=>{O()},[]);const S=k.useMemo(()=>{if(!y.searchText)return g;let E=y.searchText?.trim();return E?(E=wr.toAddress(E).toLocaleLowerCase(),g.filter(I=>I.blockletTitle.toLowerCase().includes(E)||I.blockletDid.toLowerCase().includes(E))):g},[g,y.searchText]);if(!g&&d)return e.jsx(a,{sx:{display:"flex",justifyContent:"center",alignItems:"center",marginTop:"40px"},children:e.jsx(Ge,{})});if(!g)return null;if(!g.length)return e.jsxs(a,{sx:{display:"flex",flexDirection:"column",alignItems:"center",pt:10},children:[e.jsx(a,{sx:{fontSize:20,fontWeight:"bold",mb:3},children:r("blocklet.publish.blockletEmptyTip")}),e.jsx(a,{sx:{fontSize:14,color:"text.secondary",mb:3},children:r("blocklet.publish.createBlockletTip")}),e.jsx(Ae,{onClick:N,variant:"contained",children:r("blocklet.publish.createBlocklet")})]});const Z=[{label:"Blocklet",name:"blockletTitle",minWidth:160,options:{customBodyRenderLite:E=>{const I=g[E];return e.jsx(we,{to:`${I.id}`,children:e.jsx(zt,{did:x.meta.did,projectId:I.id,logo:I.blockletLogo,title:I.blockletTitle,describe:I.blockletDescription})})}}},{label:"Version",name:"blockletVersion",options:{searchable:!1,customBodyRender:E=>E?e.jsx(qo,{type:"success",children:E}):""}},{label:"DID",name:"blockletDid",options:{customBodyRender:E=>E?e.jsx(Ct,{size:14,compact:!0,responsive:!1,did:E}):null}},h||v?null:{label:r("common.createdBy"),name:"createdBy",options:{customBodyRender:E=>E?e.jsx(Ct,{onClick:()=>{o(`${F.WELLKNOWN_SERVICE_PATH_PREFIX}/admin/members?did=${E}`)},style:{cursor:"pointer"},size:14,compact:!0,copyable:!1,showQrcode:!1,responsive:!1,did:E}):null}},h||v?null:{label:r("common.scope"),name:"componentDid",options:{customBodyRender:E=>{const I=(x.children||[]).find(V=>V.meta.did===E);return I?e.jsxs(a,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-start"},children:[e.jsx(_t,{size:14,blocklet:I,ancestors:[x]}),e.jsx(a,{sx:{ml:.5,color:"text.primary",fontSize:14},children:I.meta.title})]},E):""}}},h||s?null:{label:r("blocklet.publish.tenantScope"),name:"tenantScope",options:{customBodyRender:E=>e.jsx(a,{sx:{ml:.5,color:"text.primary",fontSize:14},children:e.jsx(Te,{children:E})})}},{label:r("common.updatedAt"),name:"updatedAt",options:{searchable:!1,customBodyRender:E=>e.jsx(No,{value:Number(E),locale:l})}},{label:r("common.actions"),name:"actions",options:{searchable:!1,customBodyRenderLite:E=>{const I=g[E];return e.jsxs(a,{sx:{display:"flex"},children:[e.jsx(we,{to:`${I.id}/new-release/none/${I.lastReleaseId}`,children:e.jsx(xe,{title:r("blocklet.publish.createRelease"),placement:"top",children:e.jsx(ce,{color:"primary","aria-label":"create",children:e.jsx(_s,{style:{fontSize:18}})})})}),!!I.lastReleaseId&&e.jsx(xe,{title:r("blocklet.publish.viewLastRelease",{name:I.blockletTitle}),placement:"top",children:e.jsx(ce,{color:"secondary","aria-label":"create",children:e.jsx(we,{style:{display:"flex"},to:`${I.id}/view/${I.lastReleaseId}/${I.blockletVersion}`,children:e.jsx(Ws,{sx:{fontSize:18}})})})}),e.jsx(xe,{title:r("blocklet.publish.delete",{name:I.blockletTitle}),placement:"top",children:e.jsx(ce,{color:"primary","aria-label":"delete",onClick:()=>z(I),children:e.jsx(go,{sx:{fontSize:18}})})})]})}}}].filter(Boolean),H=({page:E,rowsPerPage:I,searchText:V})=>{y.pageSize!==I?T(U=>({...U,searchText:"",pageSize:I,page:1})):y.page!==E+1?T(U=>({...U,searchText:"",page:E+1})):y.searchText!==V&&T(U=>({...U,searchText:V,page:1}))},Q=f?e.jsx(hr,{open:!0,popup:!0,onClose:P,action:"check-has-project-id",locale:l,checkFn:i.get,saveConnect:!1,forceConnected:!1,checkTimeout:5*60*1e3,onSuccess:w,onError:A,extraParams:{projectId:p.id,did:x.meta.did,name:p.blockletTitle},messages:{title:r("blocklet.publish.deleteProject.title",{name:p.blockletTitle}),scan:r("blocklet.publish.deleteProject.scan",{name:p.blockletTitle}),confirm:r("blocklet.publish.deleteProject.confirm"),success:r("blocklet.publish.deleteProject.success")}}):null;return e.jsxs(Vr,{children:[e.jsx(Wt,{sx:{mb:2},left:e.jsxs(a,{sx:{display:"flex",flexDirection:"row",alignItems:"center"},children:[e.jsx(a,{sx:{fontSize:"1.2rem",fontWeight:"bold"},children:r("common.blockletStudio")}),e.jsx(xe,{title:r("blocklet.publish.createBlockletTip"),arrow:!0,placement:"right",children:e.jsx(Os,{sx:{opacity:.6,fontSize:"1.1em",ml:1}})})]}),actions:e.jsxs(e.Fragment,{children:[e.jsx(vr,{options:{searchPlaceholder:r("blocklet.list.searchPlaceholder"),searchDebounceTime:600,searchAlwaysOpen:j},search:y.searchText,searchText:y.searchText,searchTextUpdate:E=>T(I=>({...I,searchText:E})),searchClose:()=>T(E=>({...E,searchText:""})),onSearchOpen:()=>{}}),e.jsxs(Ae,{onClick:N,variant:"contained",children:[e.jsx(nt,{style:{fontSize:"1.3em",marginRight:4}}),r("blocklet.publish.createBlocklet")]})]})}),e.jsx($t,{className:"main-table",locale:l,data:S,columns:Z,options:{search:!1,sort:!1,download:!1,filter:!1,print:!1,viewColumns:!1,searchAlwaysOpen:!0,rowsPerPageOptions:[10,20,50,100]},durable:D,onChange:H}),p&&e.jsx(at,{title:`${r("common.delete")} ${p.blockletTitle}`,description:r("blocklet.publish.deleteProject.description"),confirm:r("common.confirm"),onConfirm:K,onCancel:()=>m(null),children:e.jsx(a,{sx:{marginTop:2},children:[r("blocklet.publish.deleteProject.tip1"),r("blocklet.publish.deleteProject.tip2"),r("blocklet.publish.deleteProject.tip3")].map(E=>e.jsxs(a,{sx:{display:"flex",marginTop:1,flexDirection:"row",alignItems:"flex-start"},children:[e.jsx(zs,{color:"warning",sx:{marginRight:1,fontSize:20,marginTop:"2px"}}),e.jsx($,{component:"span",variant:"inherit",sx:{color:"text.secondary"},children:E})]}))})}),Q]})}const Vr=ko(a)`
2
+ import{r as k,i as It,j as rt,L as we,g as xo,k as qs,l as Ns,m as bt}from"./vendor-react-CUXIiAnY.js";import{J as Oe,j as e,ak as a,b4 as Et,W as n,am as xe,I as ce,dx as _s,dy as Ws,bb as go,cb as nt,dz as Os,a_ as zs,T as $,s as ko,cy as jo,dA as Bs,cP as Vs,Y as lt,at as ve,av as Us,dB as Ms,a5 as He,aX as it,bd as Pt,c7 as Fs,bh as Hs,b6 as Me,cX as Js,bi as et,Q as G,a6 as Se,bE as Xs,O as yo,K as wo,P as Lt,ai as vo,o as Co,M as be,a3 as Gs,bC as Ro,$ as So,bw as Ks,A as Xe,aJ as Ys,R as To,z as ne,b1 as Re,dC as Xt,bX as tt,dD as Do,V as Io,S as At,aP as Eo,bD as Zs,D as Po,cs as Qs,aQ as er,aR as tr,ct as or,cu as sr,bF as Lo,aq as rr,dE as nr,a1 as Ao,a0 as ot,bj as Gt,bP as lr,bQ as ir,dF as cr,dG as ar,bc as vt,y as dr,F as ur,bq as pr,br as ft}from"./vendor-mui-core-DHT36AZL.js";import{c as F,_ as ke,ac as De,v as hr,Y as me,bO as mr,Z as br,e as Kt,bP as fr,az as Yt,b8 as xr,bx as gr,bQ as kr,bR as jr,bS as yr}from"./index-lFDZOk_k.js";import{V as X,a2 as $o,x as wr,n as Ae,Q as qo,z as No,P as vr,h as $t,H as W,q as qt,aK as Nt,U as ae,_ as _o,A as We,b as ct,j as Wo}from"./vendor-ux-sqP3hEhY.js";import{C as at}from"./confirm-Dge1BR0a.js";import{u as ze}from"./session-DR7jqIW5.js";import{W as Ct}from"./did-address-CihvGtuj.js";import{E as Ge}from"./empty-spinner-2ylB84wv.js";import{B as _t}from"./bundle-avatar-DACPWlAj.js";import{S as Te}from"./shorten-label-Cf--RqV-.js";import{L as Wt}from"./list-header-CA-QkwGq.js";import{K as Cr,C as ue,A as Ot,D as Oo,a0 as Rr}from"./vendor-utils-BSZ4yJws.js";import{C as zo}from"./click-to-copy-DZ_4RDjR.js";import{t as Zt}from"./question-mark-circle.svg-DK9nTUDZ.js";import{l as Sr,b as Tr}from"./vendor-hooks-fhL5FJET.js";import{u as Fe}from"./useSetState-cWrp7qoX.js";import{e as Dr}from"./engine-BCYKeHn7.js";import"./api-DIucIOLX.js";import{T as Ir,S as Er}from"./vendor-mui-x-B4OOX5Es.js";import{D as Qt,C as eo,P as to}from"./react-beautiful-dnd.esm--C1KYPc1.js";import{u as Bo,c as Pr,w as Lr,a as Ar,b as $r}from"./wait-connect-DDyEqw4h.js";import{f as ge}from"./index-DBs9Ljax.js";import{c as qr,A as Vo,S as Nr,U as _r,r as Wr}from"./item-weuCOdTL.js";import{D as Or}from"./delete-confirm-CaK42Rqi.js";import{g as Uo}from"./get-safe-url-CxrqaBih.js";import{u as Le}from"./index-B9Igf2rm.js";import{M as zr}from"./index-CO3X6G_g.js";import{r as Br}from"./index-yGC4DbEU.js";import"./vendor-arcblock-3xKfH3F1.js";import"./lottie-web-4koyQiv_.js";import"./raf-schd.esm-JNUhxcps.js";function zt({did:t,projectId:o,title:s,logo:r,describe:l}){const i=`${`${F.WELLKNOWN_SERVICE_PATH_PREFIX}/api/project/${t}/${o}/logo/upload`}/${r}`,[d,u]=k.useState(!1),x=Oe(p=>p.breakpoints.down("md"));return e.jsxs(a,{sx:{display:"flex",flexDirection:"row",color:d?"primary.main":"grey.900",gap:1},onPointerEnter:()=>u(!0),onPointerLeave:()=>u(!1),children:[e.jsx(Et,{sx:{borderRadius:1},src:i}),e.jsxs(a,{children:[e.jsx(Te,{hiddenTip:!0,maxLength:"24",sx:{fontSize:"14px",fontWeight:"500",color:x?"primary.main":""},children:s||"/"}),e.jsx(Te,{hiddenTip:!0,maxLength:"58",sx:{fontSize:"12px",color:x||d?"primary.main":"grey.700"},children:l||"/"})]})]})}zt.propTypes={projectId:n.string.isRequired,did:n.string.isRequired,title:n.string.isRequired,logo:n.string.isRequired,describe:n.string.isRequired};function Mo({initUrl:t=null}){const o=It(),s=t?.searchParams.get("tenantScope")||"",{t:r,locale:l}=X(),{api:c}=ke(),{api:i}=ze(),[d,u]=k.useState(!0),{blocklet:x}=De(),[p,m]=k.useState(null),[f,b]=k.useState(!1),h=Oe(E=>E.breakpoints.down("xl")),j=Oe(E=>E.breakpoints.down("md")),{componentDid:v=""}=rt(),[g,C]=k.useState(null),D=`publish-${x.meta.did}`,R=$o(D),[y,T]=k.useState({searchText:R.searchText||"",pageSize:R.rowsPerPage||10,page:1}),O=()=>{c.getProjects({input:{did:x.meta.did,componentDid:v,tenantScope:s}}).then(E=>{const I=E?.projects||[];u(!1),C(I)}).catch(E=>{u(!1),W.error(E.message)})},N=()=>{o(`${F.UNOWNED_DID}/create/none/0.0.0`,{replace:!0})},z=E=>{m(E)},K=()=>{u(!1),b(!0)},P=()=>{b(!1),m(null)},A=E=>{W.error(E.message),b(!1),m(null)},w=E=>{if(!E?.deleted){W.error("Delete project failed");return}O(),b(!1),m(null)};k.useEffect(()=>{O()},[]);const S=k.useMemo(()=>{if(!y.searchText)return g;let E=y.searchText?.trim();return E?(E=wr.toAddress(E).toLocaleLowerCase(),g.filter(I=>I.blockletTitle.toLowerCase().includes(E)||I.blockletDid.toLowerCase().includes(E))):g},[g,y.searchText]);if(!g&&d)return e.jsx(a,{sx:{display:"flex",justifyContent:"center",alignItems:"center",marginTop:"40px"},children:e.jsx(Ge,{})});if(!g)return null;if(!g.length)return e.jsxs(a,{sx:{display:"flex",flexDirection:"column",alignItems:"center",pt:10},children:[e.jsx(a,{sx:{fontSize:20,fontWeight:"bold",mb:3},children:r("blocklet.publish.blockletEmptyTip")}),e.jsx(a,{sx:{fontSize:14,color:"text.secondary",mb:3},children:r("blocklet.publish.createBlockletTip")}),e.jsx(Ae,{onClick:N,variant:"contained",children:r("blocklet.publish.createBlocklet")})]});const Z=[{label:"Blocklet",name:"blockletTitle",minWidth:160,options:{customBodyRenderLite:E=>{const I=g[E];return e.jsx(we,{to:`${I.id}`,children:e.jsx(zt,{did:x.meta.did,projectId:I.id,logo:I.blockletLogo,title:I.blockletTitle,describe:I.blockletDescription})})}}},{label:"Version",name:"blockletVersion",options:{searchable:!1,customBodyRender:E=>E?e.jsx(qo,{type:"success",children:E}):""}},{label:"DID",name:"blockletDid",options:{customBodyRender:E=>E?e.jsx(Ct,{size:14,compact:!0,responsive:!1,did:E}):null}},h||v?null:{label:r("common.createdBy"),name:"createdBy",options:{customBodyRender:E=>E?e.jsx(Ct,{onClick:()=>{o(`${F.WELLKNOWN_SERVICE_PATH_PREFIX}/admin/members?did=${E}`)},style:{cursor:"pointer"},size:14,compact:!0,copyable:!1,showQrcode:!1,responsive:!1,did:E}):null}},h||v?null:{label:r("common.scope"),name:"componentDid",options:{customBodyRender:E=>{const I=(x.children||[]).find(V=>V.meta.did===E);return I?e.jsxs(a,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-start"},children:[e.jsx(_t,{size:14,blocklet:I,ancestors:[x]}),e.jsx(a,{sx:{ml:.5,color:"text.primary",fontSize:14},children:I.meta.title})]},E):""}}},h||s?null:{label:r("blocklet.publish.tenantScope"),name:"tenantScope",options:{customBodyRender:E=>e.jsx(a,{sx:{ml:.5,color:"text.primary",fontSize:14},children:e.jsx(Te,{children:E})})}},{label:r("common.updatedAt"),name:"updatedAt",options:{searchable:!1,customBodyRender:E=>e.jsx(No,{value:Number(E),locale:l})}},{label:r("common.actions"),name:"actions",options:{searchable:!1,customBodyRenderLite:E=>{const I=g[E];return e.jsxs(a,{sx:{display:"flex"},children:[e.jsx(we,{to:`${I.id}/new-release/none/${I.lastReleaseId}`,children:e.jsx(xe,{title:r("blocklet.publish.createRelease"),placement:"top",children:e.jsx(ce,{color:"primary","aria-label":"create",children:e.jsx(_s,{style:{fontSize:18}})})})}),!!I.lastReleaseId&&e.jsx(xe,{title:r("blocklet.publish.viewLastRelease",{name:I.blockletTitle}),placement:"top",children:e.jsx(ce,{color:"secondary","aria-label":"create",children:e.jsx(we,{style:{display:"flex"},to:`${I.id}/view/${I.lastReleaseId}/${I.blockletVersion}`,children:e.jsx(Ws,{sx:{fontSize:18}})})})}),e.jsx(xe,{title:r("blocklet.publish.delete",{name:I.blockletTitle}),placement:"top",children:e.jsx(ce,{color:"primary","aria-label":"delete",onClick:()=>z(I),children:e.jsx(go,{sx:{fontSize:18}})})})]})}}}].filter(Boolean),H=({page:E,rowsPerPage:I,searchText:V})=>{y.pageSize!==I?T(U=>({...U,searchText:"",pageSize:I,page:1})):y.page!==E+1?T(U=>({...U,searchText:"",page:E+1})):y.searchText!==V&&T(U=>({...U,searchText:V,page:1}))},Q=f?e.jsx(hr,{open:!0,popup:!0,onClose:P,action:"check-has-project-id",locale:l,checkFn:i.get,saveConnect:!1,forceConnected:!1,checkTimeout:5*60*1e3,onSuccess:w,onError:A,extraParams:{projectId:p.id,did:x.meta.did,name:p.blockletTitle},messages:{title:r("blocklet.publish.deleteProject.title",{name:p.blockletTitle}),scan:r("blocklet.publish.deleteProject.scan",{name:p.blockletTitle}),confirm:r("blocklet.publish.deleteProject.confirm"),success:r("blocklet.publish.deleteProject.success")}}):null;return e.jsxs(Vr,{children:[e.jsx(Wt,{sx:{mb:2},left:e.jsxs(a,{sx:{display:"flex",flexDirection:"row",alignItems:"center"},children:[e.jsx(a,{sx:{fontSize:"1.2rem",fontWeight:"bold"},children:r("common.blockletStudio")}),e.jsx(xe,{title:r("blocklet.publish.createBlockletTip"),arrow:!0,placement:"right",children:e.jsx(Os,{sx:{opacity:.6,fontSize:"1.1em",ml:1}})})]}),actions:e.jsxs(e.Fragment,{children:[e.jsx(vr,{options:{searchPlaceholder:r("blocklet.list.searchPlaceholder"),searchDebounceTime:600,searchAlwaysOpen:j},search:y.searchText,searchText:y.searchText,searchTextUpdate:E=>T(I=>({...I,searchText:E})),searchClose:()=>T(E=>({...E,searchText:""})),onSearchOpen:()=>{}}),e.jsxs(Ae,{onClick:N,variant:"contained",children:[e.jsx(nt,{style:{fontSize:"1.3em",marginRight:4}}),r("blocklet.publish.createBlocklet")]})]})}),e.jsx($t,{className:"main-table",locale:l,data:S,columns:Z,options:{search:!1,sort:!1,download:!1,filter:!1,print:!1,viewColumns:!1,searchAlwaysOpen:!0,rowsPerPageOptions:[10,20,50,100]},durable:D,onChange:H}),p&&e.jsx(at,{title:`${r("common.delete")} ${p.blockletTitle}`,description:r("blocklet.publish.deleteProject.description"),confirm:r("common.confirm"),onConfirm:K,onCancel:()=>m(null),children:e.jsx(a,{sx:{marginTop:2},children:[r("blocklet.publish.deleteProject.tip1"),r("blocklet.publish.deleteProject.tip2"),r("blocklet.publish.deleteProject.tip3")].map(E=>e.jsxs(a,{sx:{display:"flex",marginTop:1,flexDirection:"row",alignItems:"flex-start"},children:[e.jsx(zs,{color:"warning",sx:{marginRight:1,fontSize:20,marginTop:"2px"}}),e.jsx($,{component:"span",variant:"inherit",sx:{color:"text.secondary"},children:E})]}))})}),Q]})}const Vr=ko(a)`
3
3
  ${({theme:t})=>t.breakpoints.down("md")} {
4
4
  .MuiTableRow-root {
5
5
  border-color: ${({theme:t})=>t.palette.divider};
@@ -142,7 +142,7 @@ import{r as k,i as It,j as rt,L as we,g as xo,k as qs,l as Ns,m as bt}from"./ven
142
142
  background: #fff;
143
143
  z-index: 10;
144
144
  }
145
- `,co="lastWantToConnectStoreId";function rn(t){const[o,s]=k.useState(null),{session:r}=ze(),l=k.useCallback(d=>{s(d),localStorage.setItem(co,d?.id)},[s]),c=k.useMemo(()=>{const d=localStorage.getItem(co),u=d?(t?.settings?.storeList||[]).find(p=>p.id===d):null;if(u)return u;let x=(t?.settings?.storeList||[]).find(p=>!(p.id!==F.BLOCKLET_STORE.id||p.scope&&p.scope!=="studio"&&p.scope!==r?.user?.did));return x||(x=t?.settings?.storeList?.[0]),x},[t?.settings?.storeList,r?.user?.did]);return[o||c||{},l]}const Bt=({fromBlocklet:t,nodeInfo:o,blocklet:s,userDid:r})=>{const l=t?s?.meta?.did:o?.did;let c=t?s?.settings?.storeList||[]:o?.blockletRegistryList||[];return Array.isArray(c)||(c=[]),c=c.filter(i=>i.protected||Rr(i.scope)||i.scope==="studio"||i.scope===r),{teamDid:l,storeList:c}};function ts({blocklet:t=null,store:o=null,onChangeStore:s,onClick:r,disabled:l,loading:c,componentDid:i}){const{t:d}=X(),{session:u}=ze(),{api:x,info:p,inService:m}=ke(),f=De(),[b,h]=k.useState(!1),j=k.useRef(null),[v,g]=k.useState(!1),[C,D]=k.useState(null),R=A=>{s(A),h(!1)},y=()=>{h(!b)},T=A=>{j.current&&j.current.contains(A.target)||h(!1)},O=()=>{g(!0)},N=()=>{g(!1)},z=async()=>{if(C)try{await x.deleteBlockletStore({input:{teamDid:t.meta.did,url:C.url,projectId:"",scope:C.scope||"studio"}}),await f?.actions?.refreshBlocklet()}catch(A){W.error(`Remove Blocklet Store Error: ${ge(A)}`)}finally{D(null)}},{storeList:K}=Bt({fromBlocklet:m,blocklet:t,nodeInfo:p,userDid:u?.user?.did}),P=t?.meta?.did;return e.jsxs(e.Fragment,{children:[e.jsxs(et,{disabled:l,ref:j,variant:"contained",color:"primary","aria-label":"Button group with connect store",children:[e.jsxs(G,{onClick:r,children:[c&&e.jsx(Se,{size:14,sx:{mr:.5}}),`${d("common.connect")} ${o.name||""}`]}),e.jsx(G,{size:"small","aria-controls":b?"split-button-menu":void 0,"aria-expanded":b?"true":void 0,"aria-label":"select merge strategy","aria-haspopup":"menu",onClick:y,children:e.jsx(Xs,{})})]}),e.jsx(yo,{sx:{zIndex:10},open:b,anchorEl:j.current,placement:"bottom-end",role:void 0,transition:!0,disablePortal:!0,children:({TransitionProps:A})=>e.jsx(wo,{...A,style:{transformOrigin:"center top"},children:e.jsx(Lt,{children:e.jsx(vo,{onClickAway:T,children:e.jsxs(Co,{id:"split-button-menu",autoFocusItem:!0,sx:{maxHeight:300,overflowY:"auto",zIndex:10},children:[K?.map(w=>e.jsxs(be,{selected:w.id===o?.id,sx:{height:56},onClick:()=>R(w),children:[e.jsxs(a,{children:[e.jsx(Te,{sx:{fontSize:"16px"},maxLength:24,children:w.name}),e.jsx(Te,{sx:{fontSize:"13px",opacity:.6},maxLength:30,children:w.url})]}),qr({store:w,userDid:u?.user?.did})&&e.jsx(ce,{sx:{ml:1},onClick:S=>{S.preventDefault(),S.stopPropagation(),D(w)},children:e.jsx(ae,{icon:"ic:outline-delete"})})]},w.url)),e.jsx(Gs,{}),e.jsxs(be,{onClick:O,children:[e.jsx(nt,{font:!0}),e.jsx($,{variant:"inherit",children:d("store.blockletRegistry.addRegistry")})]})]})})})})}),v&&e.jsx(Vo,{hiddenChildren:!0,open:!0,onClose:N,teamDid:P,storeList:K,scope:"studio",onAdd:f?.actions?.refreshBlocklet}),C&&e.jsx(at,{displayError:!0,title:`${d("common.delete")} ${C.name}`,description:d("blocklet.publish.deleteStoreTip",{name:C.name}),confirm:d("common.confirm"),onConfirm:z,onCancel:()=>D(null)})]})}ts.propTypes={store:n.object,blocklet:n.object,onChangeStore:n.func.isRequired,onClick:n.func.isRequired,loading:n.bool.isRequired,disabled:n.bool.isRequired,componentDid:n.string.isRequired,projectType:n.string.isRequired,getData:n.func.isRequired};const os=(t,o,s)=>{const r=`${F.WELLKNOWN_SERVICE_PATH_PREFIX}/api/project/${o.meta.did}/${s}/logo/upload`,l=`${F.WELLKNOWN_SERVICE_PATH_PREFIX}/api/project/${o.meta.did}/${s}/screenshot/upload`,c=t?.blockletLogo?`${r}/${t.blockletLogo}`:`${F.WELLKNOWN_SERVICE_PATH_PREFIX}/static/images/logo.png`,i=(t?.blockletScreenshots||[]).filter(Boolean).map(d=>`${l}/${d}`);return{logoUrl:c,screenshotUrls:i,uploadLogoPrefix:r,uploadScreenshotPrefix:l}},nn=t=>{const o=t.includes("youtube.com")||t.includes("youtu.be"),s=t.includes("vimeo.com");return o||s};function Vt({url:t,style:o={},controls:s=1,modestbranding:r=1}){const{t:l}=X(),c=t.includes("youtube.com")||t.includes("youtu.be"),i=t.includes("vimeo.com");if(c){const d=t.split("v=")[1]?.split("&")[0]||t.split("/").pop();return e.jsx("div",{style:{position:"relative",width:"100%",paddingTop:"56.25%",pointerEvents:o?.pointerEvents||"auto"},children:e.jsx("iframe",{src:`https://www.youtube.com/embed/${d}?modestbranding=${r}&controls=${s}&rel=0`,title:"YouTube video player",style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",border:"none",...o},allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})}if(i){const d=t.split("/").pop();return e.jsx("div",{style:{position:"relative",width:"100%",paddingTop:"56.25%",pointerEvents:o.pointerEvents||"auto"},children:e.jsx("iframe",{src:`https://player.vimeo.com/video/${d}`,title:"Vimeo video player",style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",border:"none",...o},allow:"autoplay; fullscreen; picture-in-picture",allowFullScreen:!0})})}return e.jsx(a,{style:{position:"relative",width:"100%",paddingTop:"56.25%"},children:e.jsxs(a,{style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",border:"none",backgroundColor:"rgba(0, 0, 0, 0.04)",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",...o},allow:"autoplay; fullscreen; picture-in-picture",allowFullScreen:!0,children:[e.jsx(ae,{icon:"carbon:video-off",style:{fontSize:40,marginBottom:"10px",opacity:.5}}),e.jsx($,{variant:"body1",sx:{opacity:.5},children:l("studio.videoDialogNoSrc")})]})})}Vt.propTypes={url:n.string.isRequired,style:n.object,controls:n.number,modestbranding:n.number};function ss({setParams:t,onClose:o,params:s}){const{t:r}=X(),[l,c]=k.useState(""),i=l&&s.blockletVideos.includes(l),d=nn(l),u=()=>{t(x=>{const p=[...x.blockletVideos];return p.push(l),{...x,blockletVideos:p}}),o()};return e.jsxs(lt,{open:!0,fullWidth:!0,maxWidth:"sm",children:[e.jsx(Ro,{children:r("studio.videoDialogTitle")}),e.jsxs(So,{children:[e.jsx(Ks,{fullWidth:!0,value:l,onChange:x=>c(x.target.value),placeholder:r("studio.videoInputLabel"),endAdornment:l?e.jsx(Xe,{position:"end",children:e.jsx(ce,{onClick:()=>c(""),children:e.jsx(Ys,{})})}):null,error:i}),i&&e.jsx($,{variant:"body2",color:"error",children:r("studio.duplicateVideo")}),e.jsx(Vt,{url:l,style:{marginTop:"20px",borderRadius:"4px"}})]}),e.jsxs(To,{children:[e.jsx(G,{onClick:()=>o(),children:r("studio.cancel")}),e.jsx(G,{disabled:!d||i,onClick:u,children:r("studio.confirm")})]})]})}ss.propTypes={onClose:n.func.isRequired,params:n.object.isRequired,setParams:n.func.isRequired};function Rt({errors:t,storeList:o,...s}){const{t:r}=X();return e.jsxs(a,{...s,sx:[{color:"warning.main",fontSize:"14px",border:"1px solid rgba(214, 164, 64, 0.34)",borderRadius:"4px",py:2,px:1.5,position:"relative"},...Array.isArray(s.sx)?s.sx:[s.sx]],children:[e.jsx($,{variant:"caption",sx:{fontWeight:"bold",position:"absolute",top:-10,left:12,backgroundColor:"white",px:1,width:"fit-content"},children:r("blocklet.publish.storeRule.warning")}),t&&Object.entries(t).map(([l,c])=>{const i=Object.values(c),d=o.find(u=>u.url===l);return i.length>0&&e.jsxs(a,{children:[e.jsx(xe,{title:l,children:e.jsx(a,{component:"span",sx:{cursor:"pointer"},children:d.name})}),i.map(u=>e.jsx(a,{component:"li",sx:{ml:2,wordBreak:!0},children:u},u))]},l)})]})}Rt.propTypes={errors:n.object.isRequired,storeList:n.array.isRequired};const ao=k.lazy(()=>_o(()=>import("./index-CCaP8G-5.js"),__vite__mapDeps([0,1,2]),import.meta.url).then(t=>({default:t.Uploader})));function rs({projectId:t,readOnly:o,loading:s,blocklet:r,params:l,setParams:c,paramsErrTip:i,setParamsErrTip:d,warning:u,setLoading:x,initUrl:p=null,initLogoUrl:m,setInitLogoUrl:f,componentDid:b=""}){const{t:h,locale:j}=X(),{api:v}=ke(),g=It(),C=k.useRef(null),D=k.useRef(null),[R,y]=rn(r),[T,O]=k.useState(!1),N=Bo({messageType:"connect-store-message",onOpen:()=>x(!0),onClose:()=>x(!1)}),z=async q=>{const Y=setTimeout(()=>{x(!1)},2e4),J=await Lr(v,q);x(!1),clearTimeout(Y),window.parent.postMessage({event:"studioDialog.connected",componentDid:b},"*"),g(window.location.pathname.replace(`${F.UNOWNED_DID}/create`,`${J}/create`),{replace:!0})},K=()=>{if(!l.blockletTitle){W.error(h("blocklet.publish.errorTip.noTitle"));return}if(!R?.url){W.error(h("blocklet.publish.noStoreSelected"));return}const q=Pr();N(async(Y,J)=>{try{const se=await v.connectByStudio({input:{did:r?.meta?.did,blockletTitle:l?.blockletTitle,storeUrl:R.url,storeId:R.id,storeName:R.name,type:l?.blockletComponents?.length>0?"pack":"resource",componentDid:b,messageId:q,tenantScope:p?.searchParams.get("tenantScope")||""}});if(!se?.url){W.error("failed to connect to store");return}J(se.url),z({did:r?.meta?.did,projectId:"",messageId:q})}catch(se){const de=ge(se);W.error(de),x(!1)}})},{logoUrl:P,screenshotUrls:A,uploadLogoPrefix:w,uploadScreenshotPrefix:S}=os(l,r,t),{logoErrors:Z,screenshotErrors:H,storeList:Q,hasLogoWarning:E,hasScreenshotWarning:I}=u,V=()=>o?!1:!t||t===F.UNOWNED_DID?(W.error(h("blocklet.publish.errorTip.noFirstDid")),!1):!0,U=q=>{if(!q.destination)return;const Y=Array.from(l.blockletScreenshots),[J]=Y.splice(q.source.index,1);Y.splice(q.destination.index,0,J),c(se=>({...se,blockletScreenshots:Y}))},ee=q=>{if(!q.destination)return;const Y=Array.from(l.blockletVideos),[J]=Y.splice(q.source.index,1);Y.splice(q.destination.index,0,J),c(se=>({...se,blockletVideos:Y}))};return e.jsxs(ln,{children:[e.jsx(a,{className:"section",sx:{display:"flex"},children:e.jsxs(a,{sx:{flex:1},children:[e.jsx(ne,{disabled:s||o,label:`Blocklet ${h("common.title")}`,placeholder:`Blocklet ${h("common.title")}`,autoComplete:"off",variant:"outlined",fullWidth:!0,required:!0,value:l.blockletTitle||"",onChange:q=>{d({blockletTitle:""}),c({blockletTitle:q.target.value})},error:!!i.blockletTitle,helperText:i.blockletTitle||"",slotProps:{input:{"data-cy":"blocklet-title",readOnly:o}}}),e.jsx(ne,{required:!0,label:"Blocklet DID",fullWidth:!0,readonly:!0,disabled:!0,autoComplete:"off",variant:"outlined",error:!!i.projectId,helperText:i.projectId||"",value:t===F.UNOWNED_DID?"":`did:abt:${t}`,sx:{mt:3},slotProps:{input:{"data-cy":"export-blocklet-did",endAdornment:t===F.UNOWNED_DID&&e.jsx(Xe,{position:"end",children:e.jsx(ts,{blocklet:r,store:R,componentDid:b,onChangeStore:y,disabled:!l.blockletTitle||o||s,loading:s,onClick:K})})}}}),e.jsx(ne,{disabled:s||o,label:`Blocklet ${h("common.description")}`,placeholder:`Blocklet ${h("common.description")}`,required:!0,autoComplete:"off",variant:"outlined",fullWidth:!0,value:l.blockletDescription||"",onChange:q=>{d({blockletDescription:""}),c({blockletDescription:q.target.value.slice(0,159)})},error:!!i.blockletDescription,helperText:i.blockletDescription||"",sx:{mt:3},slotProps:{input:{"data-cy":"blocklet-description",readOnly:o}}}),e.jsx(ne,{disabled:s||o,label:`Blocklet ${h("common.homepageTip")}`,placeholder:`Blocklet ${h("common.homepageTip")}`,autoComplete:"off",variant:"outlined",fullWidth:!0,value:l.blockletHomepage||"",onChange:q=>{q.target.value&&!/^(http|https):\/\//.test(q.target.value)?d({blockletHomepage:h("blocklet.publish.errorTip.invalidUrl")}):d({blockletHomepage:""}),c({blockletHomepage:q.target.value})},error:!!i.blockletHomepage,helperText:i.blockletHomepage||"",sx:{mt:3},slotProps:{input:{"data-cy":"blocklet-homepage",readOnly:o}}}),e.jsx(ne,{disabled:s||o,label:`Blocklet ${h("common.community")}`,placeholder:`Blocklet ${h("common.community")}`,autoComplete:"off",variant:"outlined",fullWidth:!0,value:l.blockletCommunity||"",onChange:q=>{q.target.value&&!/^(http|https):\/\//.test(q.target.value)?d({blockletCommunity:h("blocklet.publish.errorTip.invalidUrl")}):d({blockletCommunity:""}),c({blockletCommunity:q.target.value})},error:!!i.blockletCommunity,helperText:i.blockletCommunity||"",sx:{mt:3},slotProps:{input:{"data-cy":"blocklet-community",readOnly:o}}}),e.jsx(ne,{disabled:s||o,label:`Blocklet ${h("common.support")}`,placeholder:`Blocklet ${h("common.support")}`,autoComplete:"off",variant:"outlined",fullWidth:!0,value:l.blockletSupport||"",onChange:q=>{q.target.value&&!/^(http|https):\/\//.test(q.target.value)&&!/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(q.target.value)?d({blockletSupport:h("blocklet.publish.errorTip.invalidUrlOrEmail")}):d({blockletSupport:""}),c({blockletSupport:q.target.value})},error:!!i.blockletSupport,helperText:i.blockletSupport||"",sx:{mt:3},slotProps:{input:{"data-cy":"blocklet-support",readOnly:o}}}),e.jsx(ne,{disabled:s||o,label:`Blocklet ${h("common.repository")}`,placeholder:`Blocklet ${h("common.repository")}`,autoComplete:"off",variant:"outlined",fullWidth:!0,value:l.blockletRepository||"",onChange:q=>{q.target.value&&!/^(git|https|svn)/.test(q.target.value)?d({blockletRepository:h("blocklet.publish.errorTip.invalidUrl")}):d({blockletRepository:""}),c({blockletRepository:q.target.value})},error:!!i.blockletRepository,helperText:i.blockletRepository||"",sx:{mt:3},slotProps:{input:{"data-cy":"blocklet-repository",readOnly:o}}})]})}),e.jsx(a,{className:"section full-width",sx:{display:"flex",mt:3},children:e.jsxs(a,{sx:{flex:1,overflow:"hidden"},children:[e.jsxs(a,{sx:{display:"flex",flexDirection:"row",flexWrap:"wrap"},children:[e.jsxs(Re,{direction:"column",spacing:1,sx:{mr:2,width:"160px"},children:[e.jsx($,{variant:"subtitle1",sx:{fontWeight:"bold"},children:h("common.logo")}),e.jsxs(Re,{direction:"column",spacing:1,sx:{alignItems:"flex-start",opacity:.8,fontSize:"12px"},children:[e.jsx(a,{children:e.jsxs(a,{component:"span",children:[e.jsxs(a,{component:"span",sx:{color:"text.secondary"},children:[h("studio.type"),":"," "]}),e.jsx(a,{component:"span",sx:{color:"secondary.main"},children:"png, jpg, webp, svg"})]})}),e.jsx(a,{children:e.jsxs(a,{component:"span",children:[e.jsxs(a,{component:"span",sx:{color:"text.secondary"},children:[h("studio.ratio"),":"," "]}),e.jsx(a,{component:"span",sx:{color:"secondary.main"},children:"256x256"})]})}),e.jsx(a,{children:e.jsxs(a,{component:"span",children:[e.jsxs(a,{component:"span",sx:{color:"text.secondary"},children:[h("studio.size"),":"," "]}),e.jsx(a,{component:"span",sx:{color:"secondary.main"},children:"<500Kb"})]})})]})]}),e.jsx(a,{sx:{flex:1,cursor:o?"default":"pointer",display:"flex",alignItems:"flex-end"},children:e.jsx(Et,{variant:"square",sx:{width:80,height:80},alt:"Blocklet Logo",src:m||P,onClick:()=>{V()&&C.current?.open()}})})]}),E&&e.jsx(Rt,{errors:Z,storeList:Q,mt:3}),e.jsxs(a,{sx:{display:"flex",mt:3,flexDirection:"row",flexWrap:"wrap"},children:[e.jsxs(Re,{direction:"column",spacing:1,sx:{mr:2,width:"160px"},children:[e.jsx($,{variant:"subtitle1",sx:{fontWeight:"bold"},children:h("common.screenshot")}),e.jsxs(Re,{direction:"column",spacing:1,sx:{alignItems:"flex-start",opacity:.8,fontSize:"12px"},children:[e.jsx(a,{sx:{border:"none"},variant:"outlined",size:"small",children:e.jsxs(a,{component:"span",children:[e.jsxs(a,{component:"span",sx:{color:"text.secondary"},children:[h("studio.ratio"),":"," "]}),e.jsx(a,{component:"span",sx:{color:"secondary.main"},children:"16 / 9"})]})}),e.jsx(a,{children:e.jsxs(a,{component:"span",children:[e.jsxs(a,{component:"span",sx:{color:"text.secondary"},children:[h("studio.count"),":"," "]}),e.jsx(a,{component:"span",sx:{color:"secondary.main"},children:"1~5"})]})}),e.jsx(a,{children:e.jsxs(a,{component:"span",children:[e.jsxs(a,{component:"span",sx:{color:"text.secondary"},children:[h("studio.size"),":"," "]}),e.jsx(a,{component:"span",sx:{color:"secondary.main"},children:"<5MB"})]})}),!o&&e.jsx(a,{children:e.jsxs(a,{component:"span",children:[e.jsxs(a,{component:"span",sx:{color:"text.secondary"},children:[h("studio.order"),":"," "]}),e.jsx(a,{component:"span",sx:{color:"secondary.main"},children:h("studio.orderTip")})]})})]})]}),e.jsx(Qt,{onDragEnd:o?void 0:U,children:e.jsx(eo,{droppableId:"screenshots",direction:"horizontal",isDropDisabled:o,children:(q,Y)=>e.jsxs(a,{ref:q.innerRef,...q.droppableProps,sx:{display:"flex",alignItems:"center",flex:1,flexWrap:"wrap",minHeight:160,background:Y.isDraggingOver?"grey.100":"transparent",transition:"background-color 0.2s ease",border:Y.isDraggingOver?"2px dashed #999":"none",borderRadius:"4px"},children:[A.map((J,se)=>e.jsx(to,{draggableId:J,index:se,isDragDisabled:o,children:(de,le)=>e.jsxs(a,{ref:de.innerRef,...de.draggableProps,className:"screenshot",sx:{transform:le.isDragging?"scale(1.05)":"none",boxShadow:le.isDragging?"0 5px 10px rgba(0,0,0,0.15)":"none",transition:"transform 0.2s ease, box-shadow 0.2s ease"},children:[e.jsx("img",{alt:"screenshot",src:J}),!o&&e.jsx(ce,{...de.dragHandleProps,className:"action",style:{right:40,zIndex:10,color:"#fff"},children:e.jsx(Xt,{})}),!o&&e.jsx(ce,{className:"action",onClick:()=>{c(pe=>{const he=[...pe.blockletScreenshots];return he.splice(se,1),{...pe,blockletScreenshots:he}})},children:e.jsx(tt,{})})]})},J)),q.placeholder,A.length<5&&e.jsx(a,{onClick:()=>{V()&&D.current?.open()},sx:{display:"flex",justifyContent:"center",alignItems:"center",fontSize:40,width:240,height:135,background:"#eee",cursor:o?"default":"pointer",color:"#999",mb:2},children:"+"})]})})})]}),I&&e.jsx(Rt,{errors:H,storeList:Q}),e.jsxs(a,{sx:{display:"flex",mt:3,flexDirection:"row",flexWrap:"wrap"},children:[e.jsxs(Re,{direction:"column",spacing:1,sx:{mr:2,width:"160px"},children:[e.jsx($,{variant:"subtitle1",sx:{fontWeight:"bold"},children:h("studio.video")}),e.jsxs(Re,{direction:"column",spacing:1,sx:{alignItems:"flex-start",opacity:.8,fontSize:"12px"},children:[e.jsx(a,{children:e.jsxs(a,{component:"span",children:[e.jsxs(a,{component:"span",sx:{color:"text.secondary"},children:[h("studio.videoType"),":"," "]}),e.jsxs(a,{component:"span",sx:{color:"secondary.main"},children:[e.jsx("a",{href:"https://www.youtube.com/",target:"_blank",rel:"noreferrer",children:"Youtube"}),","," ",e.jsx("a",{href:"https://vimeo.com/",target:"_blank",rel:"noreferrer",children:"Vimeo"})]})]})}),e.jsx(a,{children:e.jsxs(a,{component:"span",children:[e.jsxs(a,{component:"span",sx:{color:"text.secondary"},children:[h("studio.count"),":"," "]}),e.jsx(a,{component:"span",sx:{color:"secondary.main"},children:"1~3"})]})}),!o&&e.jsx(a,{children:e.jsxs(a,{component:"span",children:[e.jsxs(a,{component:"span",sx:{color:"text.secondary"},children:[h("studio.order"),":"," "]}),e.jsx(a,{component:"span",sx:{color:"secondary.main"},children:h("studio.orderTip")})]})})]})]}),e.jsx(Qt,{onDragEnd:o?void 0:ee,children:e.jsx(eo,{droppableId:"videos",direction:"horizontal",isDropDisabled:o,children:(q,Y)=>e.jsxs(a,{ref:q.innerRef,...q.droppableProps,sx:{display:"flex",alignItems:"center",flex:1,flexWrap:"wrap",minHeight:160,background:Y.isDraggingOver?"#f5f5f5":"transparent",transition:"background-color 0.2s ease",border:Y.isDraggingOver?"2px dashed #999":"none",borderRadius:"4px"},children:[l.blockletVideos.map((J,se)=>e.jsx(to,{draggableId:J,index:se,isDragDisabled:o,children:(de,le)=>e.jsxs(a,{ref:de.innerRef,...de.draggableProps,className:"screenshot",sx:{transform:le.isDragging?"scale(1.05)":"none",boxShadow:le.isDragging?"0 5px 10px rgba(0,0,0,0.15)":"none",transition:"transform 0.2s ease, box-shadow 0.2s ease"},children:[e.jsx(Vt,{url:J,style:{pointerEvents:le.isDragging?"none":"auto"}}),!o&&e.jsx(ce,{...de.dragHandleProps,className:"action",style:{right:40,zIndex:10,color:"#fff"},children:e.jsx(Xt,{})}),!o&&e.jsx(ce,{className:"action",onClick:()=>{c(pe=>{const he=[...pe.blockletVideos];return he.splice(se,1),{...pe,blockletVideos:he}})},children:e.jsx(tt,{})})]})},J)),q.placeholder,l.blockletVideos.length<3&&e.jsx(a,{onClick:()=>{V()&&O(!0)},sx:{display:"flex",justifyContent:"center",alignItems:"center",fontSize:40,width:240,height:135,background:"#eee",cursor:o?"default":"pointer",color:"#999",mb:2},children:"+"})]})})})]})]})}),e.jsxs(k.Suspense,{fallback:e.jsx(Ge,{}),children:[e.jsx(ao,{ref:C,locale:j,popup:!0,onUploadFinish:q=>{c({blockletLogo:q.data.filename}),f(""),C.current?.close()},plugins:["ImageEditor"],installerProps:{disabled:!0},apiPathProps:{uploader:w,disableMediaKitPrefix:!0,disableMediaKitStatus:!0},coreProps:{restrictions:{allowedFileTypes:["image/png","image/jpeg","image/webp","image/svg+xml"],maxFileSize:1024*1024*.5,maxNumberOfFiles:1}},dashboardProps:{autoOpen:"imageEditor"},imageEditorProps:{actions:{revert:!0,rotate:!0,granularRotate:!0,flip:!0,zoomIn:!0,zoomOut:!0,cropSquare:!1,cropWidescreen:!1,cropWidescreenVertical:!1},cropperOptions:{autoCrop:!0,aspectRatio:1,initialAspectRatio:1,autoCropArea:1,croppedCanvasOptions:{minWidth:256,minHeight:256}}}},"uploader-logo"),T&&e.jsx(ss,{onClose:()=>O(!1),params:l,setParams:c}),e.jsx(ao,{ref:D,locale:j,popup:!0,onUploadFinish:q=>{c(Y=>{const J=Y.blockletScreenshots||[];return J.push(q.data?.filename),{...Y,blockletScreenshots:J}}),D.current?.close()},installerProps:{disabled:!0},plugins:["ImageEditor"],apiPathProps:{uploader:S,disableMediaKitPrefix:!0,disableMediaKitStatus:!0},coreProps:{restrictions:{allowedFileTypes:["image/*","image/svg+xml"],maxFileSize:1024*1024*5,maxNumberOfFiles:5-A.length}},imageEditorProps:{actions:{revert:!0,rotate:!0,granularRotate:!0,flip:!0,zoomIn:!0,zoomOut:!0,cropSquare:!1,cropWidescreen:!1,cropWidescreenVertical:!1},cropperOptions:{autoCrop:!0,autoCropArea:1,aspectRatio:16/9,initialAspectRatio:16/9,croppedCanvasOptions:{minWidth:1280,minHeight:720,maxWidth:1280*2,maxHeight:720*2}}}},"uploader-screenshot")]})]})}rs.propTypes={projectId:n.string.isRequired,readOnly:n.bool.isRequired,params:n.object.isRequired,setParams:n.func.isRequired,paramsErrTip:n.object.isRequired,setParamsErrTip:n.func.isRequired,warning:n.object.isRequired,loading:n.bool.isRequired,blocklet:n.object.isRequired,setLoading:n.func.isRequired,initUrl:n.object,componentDid:n.string,initLogoUrl:n.string.isRequired,setInitLogoUrl:n.func.isRequired};const ln=ve.div`
145
+ `,co="lastWantToConnectStoreId";function rn(t){const[o,s]=k.useState(null),{session:r}=ze(),l=k.useCallback(d=>{s(d),localStorage.setItem(co,d?.id)},[s]),c=k.useMemo(()=>{const d=localStorage.getItem(co),u=d?(t?.settings?.storeList||[]).find(p=>p.id===d):null;if(u)return u;let x=(t?.settings?.storeList||[]).find(p=>!(p.id!==F.BLOCKLET_STORE.id||p.scope&&p.scope!=="studio"&&p.scope!==r?.user?.did));return x||(x=t?.settings?.storeList?.[0]),x},[t?.settings?.storeList,r?.user?.did]);return[o||c||{},l]}const Bt=({fromBlocklet:t,nodeInfo:o,blocklet:s,userDid:r})=>{const l=t?s?.meta?.did:o?.did;let c=t?s?.settings?.storeList||[]:o?.blockletRegistryList||[];return Array.isArray(c)||(c=[]),c=c.filter(i=>i.protected||Rr(i.scope)||i.scope==="studio"||i.scope===r),{teamDid:l,storeList:c}};function ts({blocklet:t=null,store:o=null,onChangeStore:s,onClick:r,disabled:l,loading:c,componentDid:i}){const{t:d}=X(),{session:u}=ze(),{api:x,info:p,inService:m}=ke(),f=De(),[b,h]=k.useState(!1),j=k.useRef(null),[v,g]=k.useState(!1),[C,D]=k.useState(null),R=A=>{s(A),h(!1)},y=()=>{h(!b)},T=A=>{j.current&&j.current.contains(A.target)||h(!1)},O=()=>{g(!0)},N=()=>{g(!1)},z=async()=>{if(C)try{await x.deleteBlockletStore({input:{teamDid:t.meta.did,url:C.url,projectId:"",scope:C.scope||"studio"}}),await f?.actions?.refreshBlocklet()}catch(A){W.error(`Remove Blocklet Store Error: ${ge(A)}`)}finally{D(null)}},{storeList:K}=Bt({fromBlocklet:m,blocklet:t,nodeInfo:p,userDid:u?.user?.did}),P=t?.meta?.did;return e.jsxs(e.Fragment,{children:[e.jsxs(et,{disabled:l,ref:j,variant:"contained",color:"primary","aria-label":"Button group with connect store",children:[e.jsxs(G,{onClick:r,children:[c&&e.jsx(Se,{size:14,sx:{mr:.5}}),`${d("common.connect")} ${o.name||""}`]}),e.jsx(G,{size:"small","aria-controls":b?"split-button-menu":void 0,"aria-expanded":b?"true":void 0,"aria-label":"select merge strategy","aria-haspopup":"menu",onClick:y,children:e.jsx(Xs,{})})]}),e.jsx(yo,{sx:{zIndex:10},open:b,anchorEl:j.current,placement:"bottom-end",role:void 0,transition:!0,disablePortal:!0,children:({TransitionProps:A})=>e.jsx(wo,{...A,style:{transformOrigin:"center top"},children:e.jsx(Lt,{children:e.jsx(vo,{onClickAway:T,children:e.jsxs(Co,{id:"split-button-menu",autoFocusItem:!0,sx:{maxHeight:300,overflowY:"auto",zIndex:10},children:[K?.map(w=>e.jsxs(be,{selected:w.id===o?.id,sx:{height:56},onClick:()=>R(w),children:[e.jsxs(a,{children:[e.jsx(Te,{sx:{fontSize:"16px"},maxLength:24,children:w.name}),e.jsx(Te,{sx:{fontSize:"13px",opacity:.6},maxLength:30,children:w.url})]}),qr({store:w,userDid:u?.user?.did})&&e.jsx(ce,{sx:{ml:1},onClick:S=>{S.preventDefault(),S.stopPropagation(),D(w)},children:e.jsx(ae,{icon:"ic:outline-delete"})})]},w.url)),e.jsx(Gs,{}),e.jsxs(be,{onClick:O,children:[e.jsx(nt,{font:!0}),e.jsx($,{variant:"inherit",children:d("store.blockletRegistry.addRegistry")})]})]})})})})}),v&&e.jsx(Vo,{hiddenChildren:!0,open:!0,onClose:N,teamDid:P,storeList:K,scope:"studio",onAdd:f?.actions?.refreshBlocklet}),C&&e.jsx(at,{displayError:!0,title:`${d("common.delete")} ${C.name}`,description:d("blocklet.publish.deleteStoreTip",{name:C.name}),confirm:d("common.confirm"),onConfirm:z,onCancel:()=>D(null)})]})}ts.propTypes={store:n.object,blocklet:n.object,onChangeStore:n.func.isRequired,onClick:n.func.isRequired,loading:n.bool.isRequired,disabled:n.bool.isRequired,componentDid:n.string.isRequired,projectType:n.string.isRequired,getData:n.func.isRequired};const os=(t,o,s)=>{const r=`${F.WELLKNOWN_SERVICE_PATH_PREFIX}/api/project/${o.meta.did}/${s}/logo/upload`,l=`${F.WELLKNOWN_SERVICE_PATH_PREFIX}/api/project/${o.meta.did}/${s}/screenshot/upload`,c=t?.blockletLogo?`${r}/${t.blockletLogo}`:`${F.WELLKNOWN_SERVICE_PATH_PREFIX}/static/images/logo.png`,i=(t?.blockletScreenshots||[]).filter(Boolean).map(d=>`${l}/${d}`);return{logoUrl:c,screenshotUrls:i,uploadLogoPrefix:r,uploadScreenshotPrefix:l}},nn=t=>{const o=t.includes("youtube.com")||t.includes("youtu.be"),s=t.includes("vimeo.com");return o||s};function Vt({url:t,style:o={},controls:s=1,modestbranding:r=1}){const{t:l}=X(),c=t.includes("youtube.com")||t.includes("youtu.be"),i=t.includes("vimeo.com");if(c){const d=t.split("v=")[1]?.split("&")[0]||t.split("/").pop();return e.jsx("div",{style:{position:"relative",width:"100%",paddingTop:"56.25%",pointerEvents:o?.pointerEvents||"auto"},children:e.jsx("iframe",{src:`https://www.youtube.com/embed/${d}?modestbranding=${r}&controls=${s}&rel=0`,title:"YouTube video player",style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",border:"none",...o},allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})}if(i){const d=t.split("/").pop();return e.jsx("div",{style:{position:"relative",width:"100%",paddingTop:"56.25%",pointerEvents:o.pointerEvents||"auto"},children:e.jsx("iframe",{src:`https://player.vimeo.com/video/${d}`,title:"Vimeo video player",style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",border:"none",...o},allow:"autoplay; fullscreen; picture-in-picture",allowFullScreen:!0})})}return e.jsx(a,{style:{position:"relative",width:"100%",paddingTop:"56.25%"},children:e.jsxs(a,{style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",border:"none",backgroundColor:"rgba(0, 0, 0, 0.04)",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",...o},allow:"autoplay; fullscreen; picture-in-picture",allowFullScreen:!0,children:[e.jsx(ae,{icon:"carbon:video-off",style:{fontSize:40,marginBottom:"10px",opacity:.5}}),e.jsx($,{variant:"body1",sx:{opacity:.5},children:l("studio.videoDialogNoSrc")})]})})}Vt.propTypes={url:n.string.isRequired,style:n.object,controls:n.number,modestbranding:n.number};function ss({setParams:t,onClose:o,params:s}){const{t:r}=X(),[l,c]=k.useState(""),i=l&&s.blockletVideos.includes(l),d=nn(l),u=()=>{t(x=>{const p=[...x.blockletVideos];return p.push(l),{...x,blockletVideos:p}}),o()};return e.jsxs(lt,{open:!0,fullWidth:!0,maxWidth:"sm",children:[e.jsx(Ro,{children:r("studio.videoDialogTitle")}),e.jsxs(So,{children:[e.jsx(Ks,{fullWidth:!0,value:l,onChange:x=>c(x.target.value),placeholder:r("studio.videoInputLabel"),endAdornment:l?e.jsx(Xe,{position:"end",children:e.jsx(ce,{onClick:()=>c(""),children:e.jsx(Ys,{})})}):null,error:i}),i&&e.jsx($,{variant:"body2",color:"error",children:r("studio.duplicateVideo")}),e.jsx(Vt,{url:l,style:{marginTop:"20px",borderRadius:"4px"}})]}),e.jsxs(To,{children:[e.jsx(G,{onClick:()=>o(),children:r("studio.cancel")}),e.jsx(G,{disabled:!d||i,onClick:u,children:r("studio.confirm")})]})]})}ss.propTypes={onClose:n.func.isRequired,params:n.object.isRequired,setParams:n.func.isRequired};function Rt({errors:t,storeList:o,...s}){const{t:r}=X();return e.jsxs(a,{...s,sx:[{color:"warning.main",fontSize:"14px",border:"1px solid rgba(214, 164, 64, 0.34)",borderRadius:"4px",py:2,px:1.5,position:"relative"},...Array.isArray(s.sx)?s.sx:[s.sx]],children:[e.jsx($,{variant:"caption",sx:{fontWeight:"bold",position:"absolute",top:-10,left:12,backgroundColor:"white",px:1,width:"fit-content"},children:r("blocklet.publish.storeRule.warning")}),t&&Object.entries(t).map(([l,c])=>{const i=Object.values(c),d=o.find(u=>u.url===l);return i.length>0&&e.jsxs(a,{children:[e.jsx(xe,{title:l,children:e.jsx(a,{component:"span",sx:{cursor:"pointer"},children:d.name})}),i.map(u=>e.jsx(a,{component:"li",sx:{ml:2,wordBreak:!0},children:u},u))]},l)})]})}Rt.propTypes={errors:n.object.isRequired,storeList:n.array.isRequired};const ao=k.lazy(()=>_o(()=>import("./index-B8mnhcds.js"),__vite__mapDeps([0,1,2]),import.meta.url).then(t=>({default:t.Uploader})));function rs({projectId:t,readOnly:o,loading:s,blocklet:r,params:l,setParams:c,paramsErrTip:i,setParamsErrTip:d,warning:u,setLoading:x,initUrl:p=null,initLogoUrl:m,setInitLogoUrl:f,componentDid:b=""}){const{t:h,locale:j}=X(),{api:v}=ke(),g=It(),C=k.useRef(null),D=k.useRef(null),[R,y]=rn(r),[T,O]=k.useState(!1),N=Bo({messageType:"connect-store-message",onOpen:()=>x(!0),onClose:()=>x(!1)}),z=async q=>{const Y=setTimeout(()=>{x(!1)},2e4),J=await Lr(v,q);x(!1),clearTimeout(Y),window.parent.postMessage({event:"studioDialog.connected",componentDid:b},"*"),g(window.location.pathname.replace(`${F.UNOWNED_DID}/create`,`${J}/create`),{replace:!0})},K=()=>{if(!l.blockletTitle){W.error(h("blocklet.publish.errorTip.noTitle"));return}if(!R?.url){W.error(h("blocklet.publish.noStoreSelected"));return}const q=Pr();N(async(Y,J)=>{try{const se=await v.connectByStudio({input:{did:r?.meta?.did,blockletTitle:l?.blockletTitle,storeUrl:R.url,storeId:R.id,storeName:R.name,type:l?.blockletComponents?.length>0?"pack":"resource",componentDid:b,messageId:q,tenantScope:p?.searchParams.get("tenantScope")||""}});if(!se?.url){W.error("failed to connect to store");return}J(se.url),z({did:r?.meta?.did,projectId:"",messageId:q})}catch(se){const de=ge(se);W.error(de),x(!1)}})},{logoUrl:P,screenshotUrls:A,uploadLogoPrefix:w,uploadScreenshotPrefix:S}=os(l,r,t),{logoErrors:Z,screenshotErrors:H,storeList:Q,hasLogoWarning:E,hasScreenshotWarning:I}=u,V=()=>o?!1:!t||t===F.UNOWNED_DID?(W.error(h("blocklet.publish.errorTip.noFirstDid")),!1):!0,U=q=>{if(!q.destination)return;const Y=Array.from(l.blockletScreenshots),[J]=Y.splice(q.source.index,1);Y.splice(q.destination.index,0,J),c(se=>({...se,blockletScreenshots:Y}))},ee=q=>{if(!q.destination)return;const Y=Array.from(l.blockletVideos),[J]=Y.splice(q.source.index,1);Y.splice(q.destination.index,0,J),c(se=>({...se,blockletVideos:Y}))};return e.jsxs(ln,{children:[e.jsx(a,{className:"section",sx:{display:"flex"},children:e.jsxs(a,{sx:{flex:1},children:[e.jsx(ne,{disabled:s||o,label:`Blocklet ${h("common.title")}`,placeholder:`Blocklet ${h("common.title")}`,autoComplete:"off",variant:"outlined",fullWidth:!0,required:!0,value:l.blockletTitle||"",onChange:q=>{d({blockletTitle:""}),c({blockletTitle:q.target.value})},error:!!i.blockletTitle,helperText:i.blockletTitle||"",slotProps:{input:{"data-cy":"blocklet-title",readOnly:o}}}),e.jsx(ne,{required:!0,label:"Blocklet DID",fullWidth:!0,readonly:!0,disabled:!0,autoComplete:"off",variant:"outlined",error:!!i.projectId,helperText:i.projectId||"",value:t===F.UNOWNED_DID?"":`did:abt:${t}`,sx:{mt:3},slotProps:{input:{"data-cy":"export-blocklet-did",endAdornment:t===F.UNOWNED_DID&&e.jsx(Xe,{position:"end",children:e.jsx(ts,{blocklet:r,store:R,componentDid:b,onChangeStore:y,disabled:!l.blockletTitle||o||s,loading:s,onClick:K})})}}}),e.jsx(ne,{disabled:s||o,label:`Blocklet ${h("common.description")}`,placeholder:`Blocklet ${h("common.description")}`,required:!0,autoComplete:"off",variant:"outlined",fullWidth:!0,value:l.blockletDescription||"",onChange:q=>{d({blockletDescription:""}),c({blockletDescription:q.target.value.slice(0,159)})},error:!!i.blockletDescription,helperText:i.blockletDescription||"",sx:{mt:3},slotProps:{input:{"data-cy":"blocklet-description",readOnly:o}}}),e.jsx(ne,{disabled:s||o,label:`Blocklet ${h("common.homepageTip")}`,placeholder:`Blocklet ${h("common.homepageTip")}`,autoComplete:"off",variant:"outlined",fullWidth:!0,value:l.blockletHomepage||"",onChange:q=>{q.target.value&&!/^(http|https):\/\//.test(q.target.value)?d({blockletHomepage:h("blocklet.publish.errorTip.invalidUrl")}):d({blockletHomepage:""}),c({blockletHomepage:q.target.value})},error:!!i.blockletHomepage,helperText:i.blockletHomepage||"",sx:{mt:3},slotProps:{input:{"data-cy":"blocklet-homepage",readOnly:o}}}),e.jsx(ne,{disabled:s||o,label:`Blocklet ${h("common.community")}`,placeholder:`Blocklet ${h("common.community")}`,autoComplete:"off",variant:"outlined",fullWidth:!0,value:l.blockletCommunity||"",onChange:q=>{q.target.value&&!/^(http|https):\/\//.test(q.target.value)?d({blockletCommunity:h("blocklet.publish.errorTip.invalidUrl")}):d({blockletCommunity:""}),c({blockletCommunity:q.target.value})},error:!!i.blockletCommunity,helperText:i.blockletCommunity||"",sx:{mt:3},slotProps:{input:{"data-cy":"blocklet-community",readOnly:o}}}),e.jsx(ne,{disabled:s||o,label:`Blocklet ${h("common.support")}`,placeholder:`Blocklet ${h("common.support")}`,autoComplete:"off",variant:"outlined",fullWidth:!0,value:l.blockletSupport||"",onChange:q=>{q.target.value&&!/^(http|https):\/\//.test(q.target.value)&&!/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(q.target.value)?d({blockletSupport:h("blocklet.publish.errorTip.invalidUrlOrEmail")}):d({blockletSupport:""}),c({blockletSupport:q.target.value})},error:!!i.blockletSupport,helperText:i.blockletSupport||"",sx:{mt:3},slotProps:{input:{"data-cy":"blocklet-support",readOnly:o}}}),e.jsx(ne,{disabled:s||o,label:`Blocklet ${h("common.repository")}`,placeholder:`Blocklet ${h("common.repository")}`,autoComplete:"off",variant:"outlined",fullWidth:!0,value:l.blockletRepository||"",onChange:q=>{q.target.value&&!/^(git|https|svn)/.test(q.target.value)?d({blockletRepository:h("blocklet.publish.errorTip.invalidUrl")}):d({blockletRepository:""}),c({blockletRepository:q.target.value})},error:!!i.blockletRepository,helperText:i.blockletRepository||"",sx:{mt:3},slotProps:{input:{"data-cy":"blocklet-repository",readOnly:o}}})]})}),e.jsx(a,{className:"section full-width",sx:{display:"flex",mt:3},children:e.jsxs(a,{sx:{flex:1,overflow:"hidden"},children:[e.jsxs(a,{sx:{display:"flex",flexDirection:"row",flexWrap:"wrap"},children:[e.jsxs(Re,{direction:"column",spacing:1,sx:{mr:2,width:"160px"},children:[e.jsx($,{variant:"subtitle1",sx:{fontWeight:"bold"},children:h("common.logo")}),e.jsxs(Re,{direction:"column",spacing:1,sx:{alignItems:"flex-start",opacity:.8,fontSize:"12px"},children:[e.jsx(a,{children:e.jsxs(a,{component:"span",children:[e.jsxs(a,{component:"span",sx:{color:"text.secondary"},children:[h("studio.type"),":"," "]}),e.jsx(a,{component:"span",sx:{color:"secondary.main"},children:"png, jpg, webp, svg"})]})}),e.jsx(a,{children:e.jsxs(a,{component:"span",children:[e.jsxs(a,{component:"span",sx:{color:"text.secondary"},children:[h("studio.ratio"),":"," "]}),e.jsx(a,{component:"span",sx:{color:"secondary.main"},children:"256x256"})]})}),e.jsx(a,{children:e.jsxs(a,{component:"span",children:[e.jsxs(a,{component:"span",sx:{color:"text.secondary"},children:[h("studio.size"),":"," "]}),e.jsx(a,{component:"span",sx:{color:"secondary.main"},children:"<500Kb"})]})})]})]}),e.jsx(a,{sx:{flex:1,cursor:o?"default":"pointer",display:"flex",alignItems:"flex-end"},children:e.jsx(Et,{variant:"square",sx:{width:80,height:80},alt:"Blocklet Logo",src:m||P,onClick:()=>{V()&&C.current?.open()}})})]}),E&&e.jsx(Rt,{errors:Z,storeList:Q,mt:3}),e.jsxs(a,{sx:{display:"flex",mt:3,flexDirection:"row",flexWrap:"wrap"},children:[e.jsxs(Re,{direction:"column",spacing:1,sx:{mr:2,width:"160px"},children:[e.jsx($,{variant:"subtitle1",sx:{fontWeight:"bold"},children:h("common.screenshot")}),e.jsxs(Re,{direction:"column",spacing:1,sx:{alignItems:"flex-start",opacity:.8,fontSize:"12px"},children:[e.jsx(a,{sx:{border:"none"},variant:"outlined",size:"small",children:e.jsxs(a,{component:"span",children:[e.jsxs(a,{component:"span",sx:{color:"text.secondary"},children:[h("studio.ratio"),":"," "]}),e.jsx(a,{component:"span",sx:{color:"secondary.main"},children:"16 / 9"})]})}),e.jsx(a,{children:e.jsxs(a,{component:"span",children:[e.jsxs(a,{component:"span",sx:{color:"text.secondary"},children:[h("studio.count"),":"," "]}),e.jsx(a,{component:"span",sx:{color:"secondary.main"},children:"1~5"})]})}),e.jsx(a,{children:e.jsxs(a,{component:"span",children:[e.jsxs(a,{component:"span",sx:{color:"text.secondary"},children:[h("studio.size"),":"," "]}),e.jsx(a,{component:"span",sx:{color:"secondary.main"},children:"<5MB"})]})}),!o&&e.jsx(a,{children:e.jsxs(a,{component:"span",children:[e.jsxs(a,{component:"span",sx:{color:"text.secondary"},children:[h("studio.order"),":"," "]}),e.jsx(a,{component:"span",sx:{color:"secondary.main"},children:h("studio.orderTip")})]})})]})]}),e.jsx(Qt,{onDragEnd:o?void 0:U,children:e.jsx(eo,{droppableId:"screenshots",direction:"horizontal",isDropDisabled:o,children:(q,Y)=>e.jsxs(a,{ref:q.innerRef,...q.droppableProps,sx:{display:"flex",alignItems:"center",flex:1,flexWrap:"wrap",minHeight:160,background:Y.isDraggingOver?"grey.100":"transparent",transition:"background-color 0.2s ease",border:Y.isDraggingOver?"2px dashed #999":"none",borderRadius:"4px"},children:[A.map((J,se)=>e.jsx(to,{draggableId:J,index:se,isDragDisabled:o,children:(de,le)=>e.jsxs(a,{ref:de.innerRef,...de.draggableProps,className:"screenshot",sx:{transform:le.isDragging?"scale(1.05)":"none",boxShadow:le.isDragging?"0 5px 10px rgba(0,0,0,0.15)":"none",transition:"transform 0.2s ease, box-shadow 0.2s ease"},children:[e.jsx("img",{alt:"screenshot",src:J}),!o&&e.jsx(ce,{...de.dragHandleProps,className:"action",style:{right:40,zIndex:10,color:"#fff"},children:e.jsx(Xt,{})}),!o&&e.jsx(ce,{className:"action",onClick:()=>{c(pe=>{const he=[...pe.blockletScreenshots];return he.splice(se,1),{...pe,blockletScreenshots:he}})},children:e.jsx(tt,{})})]})},J)),q.placeholder,A.length<5&&e.jsx(a,{onClick:()=>{V()&&D.current?.open()},sx:{display:"flex",justifyContent:"center",alignItems:"center",fontSize:40,width:240,height:135,background:"#eee",cursor:o?"default":"pointer",color:"#999",mb:2},children:"+"})]})})})]}),I&&e.jsx(Rt,{errors:H,storeList:Q}),e.jsxs(a,{sx:{display:"flex",mt:3,flexDirection:"row",flexWrap:"wrap"},children:[e.jsxs(Re,{direction:"column",spacing:1,sx:{mr:2,width:"160px"},children:[e.jsx($,{variant:"subtitle1",sx:{fontWeight:"bold"},children:h("studio.video")}),e.jsxs(Re,{direction:"column",spacing:1,sx:{alignItems:"flex-start",opacity:.8,fontSize:"12px"},children:[e.jsx(a,{children:e.jsxs(a,{component:"span",children:[e.jsxs(a,{component:"span",sx:{color:"text.secondary"},children:[h("studio.videoType"),":"," "]}),e.jsxs(a,{component:"span",sx:{color:"secondary.main"},children:[e.jsx("a",{href:"https://www.youtube.com/",target:"_blank",rel:"noreferrer",children:"Youtube"}),","," ",e.jsx("a",{href:"https://vimeo.com/",target:"_blank",rel:"noreferrer",children:"Vimeo"})]})]})}),e.jsx(a,{children:e.jsxs(a,{component:"span",children:[e.jsxs(a,{component:"span",sx:{color:"text.secondary"},children:[h("studio.count"),":"," "]}),e.jsx(a,{component:"span",sx:{color:"secondary.main"},children:"1~3"})]})}),!o&&e.jsx(a,{children:e.jsxs(a,{component:"span",children:[e.jsxs(a,{component:"span",sx:{color:"text.secondary"},children:[h("studio.order"),":"," "]}),e.jsx(a,{component:"span",sx:{color:"secondary.main"},children:h("studio.orderTip")})]})})]})]}),e.jsx(Qt,{onDragEnd:o?void 0:ee,children:e.jsx(eo,{droppableId:"videos",direction:"horizontal",isDropDisabled:o,children:(q,Y)=>e.jsxs(a,{ref:q.innerRef,...q.droppableProps,sx:{display:"flex",alignItems:"center",flex:1,flexWrap:"wrap",minHeight:160,background:Y.isDraggingOver?"#f5f5f5":"transparent",transition:"background-color 0.2s ease",border:Y.isDraggingOver?"2px dashed #999":"none",borderRadius:"4px"},children:[l.blockletVideos.map((J,se)=>e.jsx(to,{draggableId:J,index:se,isDragDisabled:o,children:(de,le)=>e.jsxs(a,{ref:de.innerRef,...de.draggableProps,className:"screenshot",sx:{transform:le.isDragging?"scale(1.05)":"none",boxShadow:le.isDragging?"0 5px 10px rgba(0,0,0,0.15)":"none",transition:"transform 0.2s ease, box-shadow 0.2s ease"},children:[e.jsx(Vt,{url:J,style:{pointerEvents:le.isDragging?"none":"auto"}}),!o&&e.jsx(ce,{...de.dragHandleProps,className:"action",style:{right:40,zIndex:10,color:"#fff"},children:e.jsx(Xt,{})}),!o&&e.jsx(ce,{className:"action",onClick:()=>{c(pe=>{const he=[...pe.blockletVideos];return he.splice(se,1),{...pe,blockletVideos:he}})},children:e.jsx(tt,{})})]})},J)),q.placeholder,l.blockletVideos.length<3&&e.jsx(a,{onClick:()=>{V()&&O(!0)},sx:{display:"flex",justifyContent:"center",alignItems:"center",fontSize:40,width:240,height:135,background:"#eee",cursor:o?"default":"pointer",color:"#999",mb:2},children:"+"})]})})})]})]})}),e.jsxs(k.Suspense,{fallback:e.jsx(Ge,{}),children:[e.jsx(ao,{ref:C,locale:j,popup:!0,onUploadFinish:q=>{c({blockletLogo:q.data.filename}),f(""),C.current?.close()},plugins:["ImageEditor"],installerProps:{disabled:!0},apiPathProps:{uploader:w,disableMediaKitPrefix:!0,disableMediaKitStatus:!0},coreProps:{restrictions:{allowedFileTypes:["image/png","image/jpeg","image/webp","image/svg+xml"],maxFileSize:1024*1024*.5,maxNumberOfFiles:1}},dashboardProps:{autoOpen:"imageEditor"},imageEditorProps:{actions:{revert:!0,rotate:!0,granularRotate:!0,flip:!0,zoomIn:!0,zoomOut:!0,cropSquare:!1,cropWidescreen:!1,cropWidescreenVertical:!1},cropperOptions:{autoCrop:!0,aspectRatio:1,initialAspectRatio:1,autoCropArea:1,croppedCanvasOptions:{minWidth:256,minHeight:256}}}},"uploader-logo"),T&&e.jsx(ss,{onClose:()=>O(!1),params:l,setParams:c}),e.jsx(ao,{ref:D,locale:j,popup:!0,onUploadFinish:q=>{c(Y=>{const J=Y.blockletScreenshots||[];return J.push(q.data?.filename),{...Y,blockletScreenshots:J}}),D.current?.close()},installerProps:{disabled:!0},plugins:["ImageEditor"],apiPathProps:{uploader:S,disableMediaKitPrefix:!0,disableMediaKitStatus:!0},coreProps:{restrictions:{allowedFileTypes:["image/*","image/svg+xml"],maxFileSize:1024*1024*5,maxNumberOfFiles:5-A.length}},imageEditorProps:{actions:{revert:!0,rotate:!0,granularRotate:!0,flip:!0,zoomIn:!0,zoomOut:!0,cropSquare:!1,cropWidescreen:!1,cropWidescreenVertical:!1},cropperOptions:{autoCrop:!0,autoCropArea:1,aspectRatio:16/9,initialAspectRatio:16/9,croppedCanvasOptions:{minWidth:1280,minHeight:720,maxWidth:1280*2,maxHeight:720*2}}}},"uploader-screenshot")]})]})}rs.propTypes={projectId:n.string.isRequired,readOnly:n.bool.isRequired,params:n.object.isRequired,setParams:n.func.isRequired,paramsErrTip:n.object.isRequired,setParamsErrTip:n.func.isRequired,warning:n.object.isRequired,loading:n.bool.isRequired,blocklet:n.object.isRequired,setLoading:n.func.isRequired,initUrl:n.object,componentDid:n.string,initLogoUrl:n.string.isRequired,setInitLogoUrl:n.func.isRequired};const ln=ve.div`
146
146
  margin-top: 24px;
147
147
  .screenshot {
148
148
  margin-bottom: 16px;
@@ -190,7 +190,7 @@ import{r as k,i as It,j as rt,L as we,g as xo,k as qs,l as Ns,m as bt}from"./ven
190
190
  padding-bottom: 12px;
191
191
  border-bottom: ${({theme:t})=>`1px solid ${t.palette.divider}`};
192
192
  }
193
- `;function fs({text:t}){const{palette:o}=Po();return t?e.jsx(zr,{style:{backgroundColor:o.background.default,color:o.text.primary},wrapperElement:{"data-color-mode":"light"},source:gr.sanitize(t),rehypePlugins:[[Br,{target:"_blank"}]]}):e.jsx(Je,{Icon:Nt})}fs.propTypes={text:n.string.isRequired};function xs({params:t,setParams:o,paramsErrTip:s,loading:r,setParamsErrTip:l,readOnly:c}){const{t:i}=X(),[d,u]=k.useState(c?"preview":"write"),x=(p,m)=>{u(m)};return e.jsxs(a,{sx:{border:"1px solid transparent",borderRadius:2},children:[e.jsxs(a,{sx:{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center"},children:[e.jsx($,{variant:"h6",sx:{fontWeight:"bold"},children:i("common.introduction")}),e.jsxs(Ao,{value:d,onChange:x,"aria-label":"wrapped label tabs example",children:[e.jsx(ot,{value:"write",label:"Write"}),e.jsx(ot,{value:"preview",label:"Preview"})]})]}),e.jsx(a,{sx:{display:d==="write"?"block":"none",width:"100%",marginTop:3},children:e.jsx(ne,{disabled:r||c,sx:{border:"none"},placeholder:`Blocklet ${i("common.introduction")}`,autoComplete:"off",variant:"outlined",fullWidth:!0,multiline:!0,minRows:4,value:t.blockletIntroduction||"",onChange:p=>{l({blockletIntroduction:""}),o({blockletIntroduction:p.target.value.slice(0,me.PROJECT.MAX_INTRO_LENGTH)})},error:!!s.blockletIntroduction,helperText:s.blockletIntroduction||"",slotProps:{input:{"data-cy":"export-blocklet-introduction",readOnly:c,endAdornment:e.jsxs(Xe,{position:"end",children:[t?.blockletIntroduction?.length||0," / ",me.PROJECT.MAX_INTRO_LENGTH]})}}})}),e.jsx(a,{sx:{display:d==="preview"?"block":"none",mt:3},children:e.jsx(fs,{text:t.blockletIntroduction||""})})]})}xs.propTypes={params:n.object.isRequired,setParams:n.func.isRequired,paramsErrTip:n.object.isRequired,setParamsErrTip:n.func.isRequired,readOnly:n.bool.isRequired,loading:n.bool.isRequired};function gs({step:t=0,ok:o=!1,active:s=0,error:r="",warning:l=!1}){let c="grey.500",i=t+1;return o&&(i=e.jsx(Lo,{sx:{fontSize:18,margin:0},color:"white"})),r||!o&&s>t?(c="error.main",i=e.jsx(Gt,{sx:{fontSize:18,margin:0},color:"white"})):l?(c="warning.main",i=e.jsx(Gt,{sx:{fontSize:18,margin:0},color:"white"})):s>=t&&(c="primary.main"),e.jsx(a,{sx:{width:24,height:24,bgcolor:c,borderRadius:"100%",color:"white",display:"flex",justifyContent:"center",fontWeight:"bold",fontSize:14,alignItems:"center"},children:i})}gs.propTypes={step:n.number,ok:n.bool,active:n.number,error:n.string,warning:n.bool};function ks({steps:t,activeStep:o,setActiveStep:s,hasSelectedResources:r=!1,params:l,loading:c,paramsErrTip:i,warning:d,viewMode:u="",projectId:x}){const{t:p}=X(),m=()=>{s(j=>j+1)},f=()=>{s(j=>j-1)},b=j=>j===0?i?.blockletTitle||i?.projectId||i?.blockletDescription||i?.blockletHomepage||i?.blockletSupport||i?.blockletCommunity||i?.blockletRepository:j===2?i?.blockletResource||i?.blockletDocker||i?.dockerImageName:j>=4?i?.blockletVersion||i?.note:"",h=u||ns({params:l,projectId:x,t:p})===null;return e.jsxs(a,{sx:{width:300,maxWidth:300,minWidth:300,padding:2,border:"1px solid",borderColor:"divider",borderRadius:1},children:[e.jsx(lr,{activeStep:o,orientation:"vertical",children:t.map((j,v)=>{const g={},C=c||!pn({params:l,projectId:x,step:v,t:p}),D=c?"":b(v);return D&&(g.optional=e.jsx($,{variant:"caption",color:"error",sx:{wordBreak:"break-word"},children:D}),g.error=!0),e.jsxs(ir,{children:[e.jsx(cr,{icon:e.jsx(gs,{error:D,warning:v===0?d.hasWarning:!1,active:h?99:o,step:v,ok:C}),sx:{cursor:"pointer",color:D?"error.main":"inherit"},disabled:!1,onClick:()=>s(v),...g,children:e.jsx($,{fontSize:"14px",fontWeight:"500",color:D||!C&&o>v?"error.main":"inherit",children:j.label})}),e.jsxs(ar,{children:[e.jsx($,{fontSize:12,children:j.description}),!h&&e.jsx(a,{sx:{mb:2},children:e.jsxs("div",{children:[v<t.length-1&&e.jsx(G,{variant:"contained",onClick:m,sx:{mt:1,mr:1},disabled:D||!C,children:p("common.continue")}),v>0&&e.jsx(G,{disabled:v===0,onClick:f,sx:{mt:1,mr:1},children:p("common.back")})]})})]})]},j.label)})}),o>=t.length-1&&e.jsx(Lt,{square:!0,elevation:0,sx:{p:3},children:e.jsx($,{fontSize:12,sx:{opacity:.5},children:"Click right top button to release"})})]})}ks.propTypes={steps:n.array.isRequired,activeStep:n.number.isRequired,setActiveStep:n.func.isRequired,params:n.object.isRequired,viewMode:n.oneOfType([n.string,n.bool]),loading:n.bool.isRequired,projectId:n.string.isRequired,hasSelectedResources:n.oneOfType([n.string,n.bool]),warning:n.object.isRequired,paramsErrTip:n.shape({projectId:n.string,blockletVersion:n.string,blockletTitle:n.string,blockletDescription:n.string,note:n.string,blockletResource:n.string,blockletHomepage:n.string,blockletSupport:n.string,blockletCommunity:n.string,blockletRepository:n.string,blockletDocker:n.object,dockerImageName:n.string}).isRequired};const mn=[".zip",".gz"],bn=1024*1024*100,fn=k.lazy(()=>_o(()=>import("./index-CCaP8G-5.js"),__vite__mapDeps([0,1,2]),import.meta.url).then(t=>({default:t.Uploader})));function js({app:t,projectId:o,readOnly:s,params:r,setParams:l,setParamsErrTip:c,error:i}){const{t:d,locale:u}=X(),x=k.useRef(null),p=()=>s?!1:!o||o===F.UNOWNED_DID?(W.error(d("blocklet.publish.errorTip.noFirstDid")),!1):!0,m=`${F.WELLKNOWN_SERVICE_PATH_PREFIX}/api/project/${t.meta.did}/${o}/resource/upload`;return e.jsxs(a,{sx:{mt:3},children:[e.jsx($,{gutterBottom:!0,children:d("blocklet.publish.resourceUpload")}),e.jsxs(Re,{direction:"row",spacing:1,sx:{alignItems:"center",flex:1,cursor:s?"default":"pointer"},children:[!!r.uploadedResource&&e.jsx($,{component:"a",href:`${m}/params.uploadedResource`,children:r.uploadedResource}),!s&&e.jsx(G,{variant:"outlined",size:"small",onClick:()=>{p()&&x.current?.open()},children:r.uploadedResource?d("common.change"):d("common.upload")})]}),e.jsx(k.Suspense,{fallback:e.jsx(Ge,{}),children:e.jsx(fn,{ref:x,locale:u,popup:!0,onUploadFinish:f=>{l({uploadedResource:f.data.filename}),c({blockletResource:""}),x.current?.close()},plugins:["ImageEditor"],installerProps:{disabled:!0},apiPathProps:{uploader:m,disableMediaKitPrefix:!0,disableMediaKitStatus:!0},coreProps:{restrictions:{allowedFileExts:mn,maxFileSize:bn,maxNumberOfFiles:1}}},"uploader-resource")}),!!i&&e.jsx(a,{sx:{color:"error.main",mt:1,fontSize:14},children:i})]})}js.propTypes={app:n.object.isRequired,projectId:n.string.isRequired,readOnly:n.bool.isRequired,params:n.object.isRequired,setParams:n.func.isRequired,error:n.string.isRequired,setParamsErrTip:n.func.isRequired};function Tt({readOnly:t,params:o,setParams:s,paramsErrTip:r,setParamsErrTip:l,loading:c}){const{t:i}=X();return e.jsx(a,{className:"section",sx:{display:"flex",mt:3},children:e.jsxs(a,{sx:{flex:1},children:[e.jsx(ne,{required:!0,disabled:c||t,label:`Blocklet ${i("common.version")}`,placeholder:`Blocklet ${i("common.version")}`,autoComplete:"off",variant:"outlined",fullWidth:!0,value:o.blockletVersion||"",onChange:d=>{l({blockletVersion:""}),s({blockletVersion:d.target.value})},error:!!r.blockletVersion,helperText:r.blockletVersion||"",slotProps:{input:{"data-cy":"blocklet-version",readOnly:t}}}),e.jsx(ne,{label:i("blocklet.publish.releaseNote"),autoComplete:"off",disabled:c||t,variant:"outlined",fullWidth:!0,multiline:!0,minRows:4,required:!0,value:o.note||"",onChange:d=>{l({note:""}),s({note:d.target.value.slice(0,me.PROJECT.MAX_NOTE_LENGTH)})},error:!!r.note,helperText:r.note||"",sx:{mt:3},slotProps:{input:{"data-cy":"release-note",readOnly:t,endAdornment:e.jsxs(Xe,{position:"end",children:[o?.note?.length||0," / ",me.PROJECT.MAX_NOTE_LENGTH]})}}})]})})}Tt.propTypes={readOnly:n.bool.isRequired,params:n.object.isRequired,setParams:n.func.isRequired,paramsErrTip:n.object.isRequired,setParamsErrTip:n.func.isRequired,loading:n.bool.isRequired};function ys(t){for(const o in t)typeof t[o]=="string"?t[o]=t[o].replace(/\\\\/g,"\\"):typeof t[o]=="object"&&t[o]!==null&&ys(t[o]);return t}var xn=Wr();const oe=xo(xn),gn={"-a":"--attach","-d":"--detach","-e":"--env","-h":"--hostname","-i":"--interactive","-it":"-it","-rm":"-rm","-m":"--memory","-p":"--publish","-P":"--publish-all","-l":"--label","-n":"--name","-q":"--quiet","-x":"--x-registry","-t":"--tty","-u":"--user","-v":"--volume","-w":"--workdir","-cgroupns":"--cgroupns","-cpus":"--cpus","-g":"--gpus","-ip6":"--ip6","--read-only":"--read-only","--add-host":"--add-host","--attach":"--attach","--blkio-weight":"--blkio-weight","--blkio-weight-device":"--blkio-weight-device","--cap-add":"--cap-add","--cap-drop":"--cap-drop","--cgroup-parent":"--cgroup-parent","--cidfile":"--cidfile","--cpu-period":"--cpu-period","--cpu-quota":"--cpu-quota","--cpu-rt-period":"--cpu-rt-period","--cpu-rt-runtime":"--cpu-rt-runtime","--cpu-shares":"--cpu-shares","--cpus":"--cpus","--cpuset-cpus":"--cpuset-cpus","--cpuset-mems":"--cpuset-mems","--detach":"--detach","--detach-keys":"--detach-keys","--device":"--device","--device-cgroup-rule":"--device-cgroup-rule","--device-read-bps":"--device-read-bps","--device-read-iops":"--device-read-iops","--device-write-bps":"--device-write-bps","--device-write-iops":"--device-write-iops","--disable-content-trust":"--disable-content-trust","--dns":"--dns","--dns-opt":"--dns-opt","--dns-search":"--dns-search","--domainname":"--domainname","--entrypoint":"--entrypoint","--env":"--env","--env-file":"--env-file","--expose":"--expose","--gpus":"--gpus","--group-add":"--group-add","--health-cmd":"--health-cmd","--health-interval":"--health-interval","--health-retries":"--health-retries","--health-start-period":"--health-start-period","--health-timeout":"--health-timeout","--help":"--help","--hostname":"--hostname","--init":"--init","--interactive":"--interactive","--ip":"--ip","--ip6":"--ip6","--ipc":"--ipc","--isolation":"--isolation","--kernel-memory":"--kernel-memory","--label":"--label","--label-file":"--label-file","--link":"--link","--link-local-ip":"--link-local-ip","--log-driver":"--log-driver","--log-opt":"--log-opt","--mac-address":"--mac-address","--memory":"--memory","--memory-reservation":"--memory-reservation","--memory-swap":"--memory-swap","--memory-swappiness":"--memory-swappiness","--mount":"--mount","--name":"--name","--network":"--network","--network-alias":"--network-alias","--no-healthcheck":"--no-healthcheck","--oom-kill-disable":"--oom-kill-disable","--oom-score-adj":"--oom-score-adj","--pid":"--pid","--pids-limit":"--pids-limit","--platform":"--platform","--privileged":"--privileged","--publish":"--publish","--publish-all":"--publish-all","--pull":"--pull","--restart":"--restart","--rm":"--rm","--runtime":"--runtime","--security-opt":"--security-opt","--shm-size":"--shm-size","--stop-signal":"--stop-signal","--stop-timeout":"--stop-timeout","--storage-opt":"--storage-opt","--sysctl":"--sysctl","--tmpfs":"--tmpfs","--tty":"--tty","--ulimit":"--ulimit","--user":"--user","--userns":"--userns","--uts":"--uts","--volume":"--volume","--volume-driver":"--volume-driver","--volumes-from":"--volumes-from","--workdir":"--workdir"},Ut={"--env":!0,"--publish":!0,"--volume":!0,"--attach":!0,"--quiet":!0,"--entrypoint":!0,"--workdir":!0,"--cidfile":!0,"--detach-keys":!0,"--disable-content-trust":!0,"--domainname":!0,"--expose":!0,"--ip":!0,"--link-local-ip":!0,"--platform":!0},kn={"--volume":!0,"--publish":!0},jn=new Set(["--publish","--volume"]),ws=t=>{const[o]=t.split(":");return o?.startsWith("/")||o?.startsWith("./")||o?.startsWith("../")||o?.startsWith("~")||o?.startsWith("$BLOCKLET")};function yn(t){return t.map(o=>{if(o.key!=="--volume"||o.value.startsWith("$BLOCKLET_APP_DIR/")||o.value.startsWith("$BLOCKLET_DATA_DIR/"))return o;const[s,...r]=o.value.split(":");if(!s||!ws(o.value))return o;const l=s.startsWith("/")?`$BLOCKLET_DATA_DIR${s}`:`$BLOCKLET_DATA_DIR/${s}`;return{...o,value:[l,...r].join(":")}})}function wn(t){let o=!0;return t.find(r=>r.key==="--publish"&&r.type==="web")?t.map(r=>{if(r.key==="--publish"){const l={...r,type:o?"docker":r.type};return o=r.type==="web",l}return r}):t.map(r=>{if(r.key==="--publish"){const l={...r,type:o?"web":"docker"};return o=!1,l}return r})}function ho(t){if(!t)return{dockerArgs:[],dockerEnvs:[],dockerImage:"",dockerCommand:""};if(t=t.trim(),t.startsWith("$ docker run")&&(t=t.replace("$ docker run","docker run")),!t.startsWith("docker run"))return{dockerArgs:[],dockerEnvs:[],dockerImage:"",dockerCommand:""};const s=t.replace(/\\\n/g,"").replace(/\n/g," ").trim().match(/(?:[^\s"']+|'[^']*'|"[^"]*")+/g);if(!s)return{dockerArgs:[],dockerEnvs:[],dockerImage:"",dockerCommand:""};const r=[],l=[];let c=0,i="",d="";const u=[];for(;c<s.length;){const p=s[c];if(!p){c++;continue}if(p==="docker"||p==="run"){c++;continue}if((p==="-e"||p==="--env")&&c+1<s.length){const m=s[c+1]||"",[f,...b]=m.split("=");if(f){const h=b.join("=").replace(/^['"]|['"]$/g,"");l.push({key:f,value:h})}c+=2;continue}if(p.startsWith("-")&&u.length===0){const m=p.indexOf("=");let f=p,b=null;m!==-1&&(f=p.substring(0,m),b=p.substring(m+1).replace(/^['"]|['"]$/g,""));const h=gn[f];if(!h){c+=2;continue}if(h==="--publish"){let j="";if(b)j=b,r.push({key:h,value:j});else if(c+1<s.length&&!(s[c+1]||"").startsWith("-")){j=(s[c+1]||"").replace(/^['"]|['"]$/g,""),r.push({key:h,value:j}),c+=2;continue}else{r.push({key:h,value:"true"}),c++;continue}c++;continue}if(b!==null){r.push({key:h,value:b}),c++;continue}else if(c+1<s.length&&!(s[c+1]||"").startsWith("-")){const j=(s[c+1]||"").replace(/^['"]|['"]$/g,"");r.push({key:h,value:j}),c+=2;continue}else{r.push({key:h,value:"true"}),c++;continue}}u.push(p),c++}i=u[0]||"",d=u.slice(1).join(" ");const x=[];for(const p of r)p.name="",p.path="",p.prefix="",p.protocol="",p.proxyBehavior="service",p.type="docker",!(jn.has(p.key)&&p.value==="true")&&x.push(p);for(const p of l)p.custom="",p.description="",p.secure=!1,p.shared=!1,p.required=!1;return{dockerArgs:wn(yn(x)),dockerEnvs:l,dockerImage:i,dockerCommand:d}}function vn({dockerArgs:t,dockerEnvs:o,dockerImage:s,dockerCommand:r}){if(t.length===0&&o.length===0&&!s)return"";const l=["docker run \\"],c=new Set(["--publish","--volume","--expose","--device","--mount","--label","--cap-add","--cap-drop","--add-host","--dns","--network-alias","--sysctl","--ulimit","--network"]);for(const i of t){const{key:d,value:u}=i;if(c.has(d))if(u==="true")l.push(` ${d} \\`);else{const x=/[\s"']/g.test(u)?`"${u}"`:u;l.push(` ${d} ${x} \\`)}else if(!l.some(x=>x.startsWith(` ${d}`)))if(u==="true")l.push(` ${d} \\`);else{const x=/[\s"']/g.test(u)?`"${u}"`:u;l.push(` ${d} ${x} \\`)}}for(const i of o){const{key:d,value:u}=i,x=/["']/g.test(u)?u:`"${u}"`;l.push(` -e ${d}=${x} \\`)}return s&&l.push(` ${s} \\`),r&&l.push(` ${r} \\`),l[l.length-1]?.endsWith(" \\")&&(l[l.length-1]=(l[l.length-1]||"").slice(0,-2)),l.join(`
193
+ `;function fs({text:t}){const{palette:o}=Po();return t?e.jsx(zr,{style:{backgroundColor:o.background.default,color:o.text.primary},wrapperElement:{"data-color-mode":"light"},source:gr.sanitize(t),rehypePlugins:[[Br,{target:"_blank"}]]}):e.jsx(Je,{Icon:Nt})}fs.propTypes={text:n.string.isRequired};function xs({params:t,setParams:o,paramsErrTip:s,loading:r,setParamsErrTip:l,readOnly:c}){const{t:i}=X(),[d,u]=k.useState(c?"preview":"write"),x=(p,m)=>{u(m)};return e.jsxs(a,{sx:{border:"1px solid transparent",borderRadius:2},children:[e.jsxs(a,{sx:{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center"},children:[e.jsx($,{variant:"h6",sx:{fontWeight:"bold"},children:i("common.introduction")}),e.jsxs(Ao,{value:d,onChange:x,"aria-label":"wrapped label tabs example",children:[e.jsx(ot,{value:"write",label:"Write"}),e.jsx(ot,{value:"preview",label:"Preview"})]})]}),e.jsx(a,{sx:{display:d==="write"?"block":"none",width:"100%",marginTop:3},children:e.jsx(ne,{disabled:r||c,sx:{border:"none"},placeholder:`Blocklet ${i("common.introduction")}`,autoComplete:"off",variant:"outlined",fullWidth:!0,multiline:!0,minRows:4,value:t.blockletIntroduction||"",onChange:p=>{l({blockletIntroduction:""}),o({blockletIntroduction:p.target.value.slice(0,me.PROJECT.MAX_INTRO_LENGTH)})},error:!!s.blockletIntroduction,helperText:s.blockletIntroduction||"",slotProps:{input:{"data-cy":"export-blocklet-introduction",readOnly:c,endAdornment:e.jsxs(Xe,{position:"end",children:[t?.blockletIntroduction?.length||0," / ",me.PROJECT.MAX_INTRO_LENGTH]})}}})}),e.jsx(a,{sx:{display:d==="preview"?"block":"none",mt:3},children:e.jsx(fs,{text:t.blockletIntroduction||""})})]})}xs.propTypes={params:n.object.isRequired,setParams:n.func.isRequired,paramsErrTip:n.object.isRequired,setParamsErrTip:n.func.isRequired,readOnly:n.bool.isRequired,loading:n.bool.isRequired};function gs({step:t=0,ok:o=!1,active:s=0,error:r="",warning:l=!1}){let c="grey.500",i=t+1;return o&&(i=e.jsx(Lo,{sx:{fontSize:18,margin:0},color:"white"})),r||!o&&s>t?(c="error.main",i=e.jsx(Gt,{sx:{fontSize:18,margin:0},color:"white"})):l?(c="warning.main",i=e.jsx(Gt,{sx:{fontSize:18,margin:0},color:"white"})):s>=t&&(c="primary.main"),e.jsx(a,{sx:{width:24,height:24,bgcolor:c,borderRadius:"100%",color:"white",display:"flex",justifyContent:"center",fontWeight:"bold",fontSize:14,alignItems:"center"},children:i})}gs.propTypes={step:n.number,ok:n.bool,active:n.number,error:n.string,warning:n.bool};function ks({steps:t,activeStep:o,setActiveStep:s,hasSelectedResources:r=!1,params:l,loading:c,paramsErrTip:i,warning:d,viewMode:u="",projectId:x}){const{t:p}=X(),m=()=>{s(j=>j+1)},f=()=>{s(j=>j-1)},b=j=>j===0?i?.blockletTitle||i?.projectId||i?.blockletDescription||i?.blockletHomepage||i?.blockletSupport||i?.blockletCommunity||i?.blockletRepository:j===2?i?.blockletResource||i?.blockletDocker||i?.dockerImageName:j>=4?i?.blockletVersion||i?.note:"",h=u||ns({params:l,projectId:x,t:p})===null;return e.jsxs(a,{sx:{width:300,maxWidth:300,minWidth:300,padding:2,border:"1px solid",borderColor:"divider",borderRadius:1},children:[e.jsx(lr,{activeStep:o,orientation:"vertical",children:t.map((j,v)=>{const g={},C=c||!pn({params:l,projectId:x,step:v,t:p}),D=c?"":b(v);return D&&(g.optional=e.jsx($,{variant:"caption",color:"error",sx:{wordBreak:"break-word"},children:D}),g.error=!0),e.jsxs(ir,{children:[e.jsx(cr,{icon:e.jsx(gs,{error:D,warning:v===0?d.hasWarning:!1,active:h?99:o,step:v,ok:C}),sx:{cursor:"pointer",color:D?"error.main":"inherit"},disabled:!1,onClick:()=>s(v),...g,children:e.jsx($,{fontSize:"14px",fontWeight:"500",color:D||!C&&o>v?"error.main":"inherit",children:j.label})}),e.jsxs(ar,{children:[e.jsx($,{fontSize:12,children:j.description}),!h&&e.jsx(a,{sx:{mb:2},children:e.jsxs("div",{children:[v<t.length-1&&e.jsx(G,{variant:"contained",onClick:m,sx:{mt:1,mr:1},disabled:D||!C,children:p("common.continue")}),v>0&&e.jsx(G,{disabled:v===0,onClick:f,sx:{mt:1,mr:1},children:p("common.back")})]})})]})]},j.label)})}),o>=t.length-1&&e.jsx(Lt,{square:!0,elevation:0,sx:{p:3},children:e.jsx($,{fontSize:12,sx:{opacity:.5},children:"Click right top button to release"})})]})}ks.propTypes={steps:n.array.isRequired,activeStep:n.number.isRequired,setActiveStep:n.func.isRequired,params:n.object.isRequired,viewMode:n.oneOfType([n.string,n.bool]),loading:n.bool.isRequired,projectId:n.string.isRequired,hasSelectedResources:n.oneOfType([n.string,n.bool]),warning:n.object.isRequired,paramsErrTip:n.shape({projectId:n.string,blockletVersion:n.string,blockletTitle:n.string,blockletDescription:n.string,note:n.string,blockletResource:n.string,blockletHomepage:n.string,blockletSupport:n.string,blockletCommunity:n.string,blockletRepository:n.string,blockletDocker:n.object,dockerImageName:n.string}).isRequired};const mn=[".zip",".gz"],bn=1024*1024*100,fn=k.lazy(()=>_o(()=>import("./index-B8mnhcds.js"),__vite__mapDeps([0,1,2]),import.meta.url).then(t=>({default:t.Uploader})));function js({app:t,projectId:o,readOnly:s,params:r,setParams:l,setParamsErrTip:c,error:i}){const{t:d,locale:u}=X(),x=k.useRef(null),p=()=>s?!1:!o||o===F.UNOWNED_DID?(W.error(d("blocklet.publish.errorTip.noFirstDid")),!1):!0,m=`${F.WELLKNOWN_SERVICE_PATH_PREFIX}/api/project/${t.meta.did}/${o}/resource/upload`;return e.jsxs(a,{sx:{mt:3},children:[e.jsx($,{gutterBottom:!0,children:d("blocklet.publish.resourceUpload")}),e.jsxs(Re,{direction:"row",spacing:1,sx:{alignItems:"center",flex:1,cursor:s?"default":"pointer"},children:[!!r.uploadedResource&&e.jsx($,{component:"a",href:`${m}/params.uploadedResource`,children:r.uploadedResource}),!s&&e.jsx(G,{variant:"outlined",size:"small",onClick:()=>{p()&&x.current?.open()},children:r.uploadedResource?d("common.change"):d("common.upload")})]}),e.jsx(k.Suspense,{fallback:e.jsx(Ge,{}),children:e.jsx(fn,{ref:x,locale:u,popup:!0,onUploadFinish:f=>{l({uploadedResource:f.data.filename}),c({blockletResource:""}),x.current?.close()},plugins:["ImageEditor"],installerProps:{disabled:!0},apiPathProps:{uploader:m,disableMediaKitPrefix:!0,disableMediaKitStatus:!0},coreProps:{restrictions:{allowedFileExts:mn,maxFileSize:bn,maxNumberOfFiles:1}}},"uploader-resource")}),!!i&&e.jsx(a,{sx:{color:"error.main",mt:1,fontSize:14},children:i})]})}js.propTypes={app:n.object.isRequired,projectId:n.string.isRequired,readOnly:n.bool.isRequired,params:n.object.isRequired,setParams:n.func.isRequired,error:n.string.isRequired,setParamsErrTip:n.func.isRequired};function Tt({readOnly:t,params:o,setParams:s,paramsErrTip:r,setParamsErrTip:l,loading:c}){const{t:i}=X();return e.jsx(a,{className:"section",sx:{display:"flex",mt:3},children:e.jsxs(a,{sx:{flex:1},children:[e.jsx(ne,{required:!0,disabled:c||t,label:`Blocklet ${i("common.version")}`,placeholder:`Blocklet ${i("common.version")}`,autoComplete:"off",variant:"outlined",fullWidth:!0,value:o.blockletVersion||"",onChange:d=>{l({blockletVersion:""}),s({blockletVersion:d.target.value})},error:!!r.blockletVersion,helperText:r.blockletVersion||"",slotProps:{input:{"data-cy":"blocklet-version",readOnly:t}}}),e.jsx(ne,{label:i("blocklet.publish.releaseNote"),autoComplete:"off",disabled:c||t,variant:"outlined",fullWidth:!0,multiline:!0,minRows:4,required:!0,value:o.note||"",onChange:d=>{l({note:""}),s({note:d.target.value.slice(0,me.PROJECT.MAX_NOTE_LENGTH)})},error:!!r.note,helperText:r.note||"",sx:{mt:3},slotProps:{input:{"data-cy":"release-note",readOnly:t,endAdornment:e.jsxs(Xe,{position:"end",children:[o?.note?.length||0," / ",me.PROJECT.MAX_NOTE_LENGTH]})}}})]})})}Tt.propTypes={readOnly:n.bool.isRequired,params:n.object.isRequired,setParams:n.func.isRequired,paramsErrTip:n.object.isRequired,setParamsErrTip:n.func.isRequired,loading:n.bool.isRequired};function ys(t){for(const o in t)typeof t[o]=="string"?t[o]=t[o].replace(/\\\\/g,"\\"):typeof t[o]=="object"&&t[o]!==null&&ys(t[o]);return t}var xn=Wr();const oe=xo(xn),gn={"-a":"--attach","-d":"--detach","-e":"--env","-h":"--hostname","-i":"--interactive","-it":"-it","-rm":"-rm","-m":"--memory","-p":"--publish","-P":"--publish-all","-l":"--label","-n":"--name","-q":"--quiet","-x":"--x-registry","-t":"--tty","-u":"--user","-v":"--volume","-w":"--workdir","-cgroupns":"--cgroupns","-cpus":"--cpus","-g":"--gpus","-ip6":"--ip6","--read-only":"--read-only","--add-host":"--add-host","--attach":"--attach","--blkio-weight":"--blkio-weight","--blkio-weight-device":"--blkio-weight-device","--cap-add":"--cap-add","--cap-drop":"--cap-drop","--cgroup-parent":"--cgroup-parent","--cidfile":"--cidfile","--cpu-period":"--cpu-period","--cpu-quota":"--cpu-quota","--cpu-rt-period":"--cpu-rt-period","--cpu-rt-runtime":"--cpu-rt-runtime","--cpu-shares":"--cpu-shares","--cpus":"--cpus","--cpuset-cpus":"--cpuset-cpus","--cpuset-mems":"--cpuset-mems","--detach":"--detach","--detach-keys":"--detach-keys","--device":"--device","--device-cgroup-rule":"--device-cgroup-rule","--device-read-bps":"--device-read-bps","--device-read-iops":"--device-read-iops","--device-write-bps":"--device-write-bps","--device-write-iops":"--device-write-iops","--disable-content-trust":"--disable-content-trust","--dns":"--dns","--dns-opt":"--dns-opt","--dns-search":"--dns-search","--domainname":"--domainname","--entrypoint":"--entrypoint","--env":"--env","--env-file":"--env-file","--expose":"--expose","--gpus":"--gpus","--group-add":"--group-add","--health-cmd":"--health-cmd","--health-interval":"--health-interval","--health-retries":"--health-retries","--health-start-period":"--health-start-period","--health-timeout":"--health-timeout","--help":"--help","--hostname":"--hostname","--init":"--init","--interactive":"--interactive","--ip":"--ip","--ip6":"--ip6","--ipc":"--ipc","--isolation":"--isolation","--kernel-memory":"--kernel-memory","--label":"--label","--label-file":"--label-file","--link":"--link","--link-local-ip":"--link-local-ip","--log-driver":"--log-driver","--log-opt":"--log-opt","--mac-address":"--mac-address","--memory":"--memory","--memory-reservation":"--memory-reservation","--memory-swap":"--memory-swap","--memory-swappiness":"--memory-swappiness","--mount":"--mount","--name":"--name","--network":"--network","--network-alias":"--network-alias","--no-healthcheck":"--no-healthcheck","--oom-kill-disable":"--oom-kill-disable","--oom-score-adj":"--oom-score-adj","--pid":"--pid","--pids-limit":"--pids-limit","--platform":"--platform","--privileged":"--privileged","--publish":"--publish","--publish-all":"--publish-all","--pull":"--pull","--restart":"--restart","--rm":"--rm","--runtime":"--runtime","--security-opt":"--security-opt","--shm-size":"--shm-size","--stop-signal":"--stop-signal","--stop-timeout":"--stop-timeout","--storage-opt":"--storage-opt","--sysctl":"--sysctl","--tmpfs":"--tmpfs","--tty":"--tty","--ulimit":"--ulimit","--user":"--user","--userns":"--userns","--uts":"--uts","--volume":"--volume","--volume-driver":"--volume-driver","--volumes-from":"--volumes-from","--workdir":"--workdir"},Ut={"--env":!0,"--publish":!0,"--volume":!0,"--attach":!0,"--quiet":!0,"--entrypoint":!0,"--workdir":!0,"--cidfile":!0,"--detach-keys":!0,"--disable-content-trust":!0,"--domainname":!0,"--expose":!0,"--ip":!0,"--link-local-ip":!0,"--platform":!0},kn={"--volume":!0,"--publish":!0},jn=new Set(["--publish","--volume"]),ws=t=>{const[o]=t.split(":");return o?.startsWith("/")||o?.startsWith("./")||o?.startsWith("../")||o?.startsWith("~")||o?.startsWith("$BLOCKLET")};function yn(t){return t.map(o=>{if(o.key!=="--volume"||o.value.startsWith("$BLOCKLET_APP_DIR/")||o.value.startsWith("$BLOCKLET_DATA_DIR/"))return o;const[s,...r]=o.value.split(":");if(!s||!ws(o.value))return o;const l=s.startsWith("/")?`$BLOCKLET_DATA_DIR${s}`:`$BLOCKLET_DATA_DIR/${s}`;return{...o,value:[l,...r].join(":")}})}function wn(t){let o=!0;return t.find(r=>r.key==="--publish"&&r.type==="web")?t.map(r=>{if(r.key==="--publish"){const l={...r,type:o?"docker":r.type};return o=r.type==="web",l}return r}):t.map(r=>{if(r.key==="--publish"){const l={...r,type:o?"web":"docker"};return o=!1,l}return r})}function ho(t){if(!t)return{dockerArgs:[],dockerEnvs:[],dockerImage:"",dockerCommand:""};if(t=t.trim(),t.startsWith("$ docker run")&&(t=t.replace("$ docker run","docker run")),!t.startsWith("docker run"))return{dockerArgs:[],dockerEnvs:[],dockerImage:"",dockerCommand:""};const s=t.replace(/\\\n/g,"").replace(/\n/g," ").trim().match(/(?:[^\s"']+|'[^']*'|"[^"]*")+/g);if(!s)return{dockerArgs:[],dockerEnvs:[],dockerImage:"",dockerCommand:""};const r=[],l=[];let c=0,i="",d="";const u=[];for(;c<s.length;){const p=s[c];if(!p){c++;continue}if(p==="docker"||p==="run"){c++;continue}if((p==="-e"||p==="--env")&&c+1<s.length){const m=s[c+1]||"",[f,...b]=m.split("=");if(f){const h=b.join("=").replace(/^['"]|['"]$/g,"");l.push({key:f,value:h})}c+=2;continue}if(p.startsWith("-")&&u.length===0){const m=p.indexOf("=");let f=p,b=null;m!==-1&&(f=p.substring(0,m),b=p.substring(m+1).replace(/^['"]|['"]$/g,""));const h=gn[f];if(!h){c+=2;continue}if(h==="--publish"){let j="";if(b)j=b,r.push({key:h,value:j});else if(c+1<s.length&&!(s[c+1]||"").startsWith("-")){j=(s[c+1]||"").replace(/^['"]|['"]$/g,""),r.push({key:h,value:j}),c+=2;continue}else{r.push({key:h,value:"true"}),c++;continue}c++;continue}if(b!==null){r.push({key:h,value:b}),c++;continue}else if(c+1<s.length&&!(s[c+1]||"").startsWith("-")){const j=(s[c+1]||"").replace(/^['"]|['"]$/g,"");r.push({key:h,value:j}),c+=2;continue}else{r.push({key:h,value:"true"}),c++;continue}}u.push(p),c++}i=u[0]||"",d=u.slice(1).join(" ");const x=[];for(const p of r)p.name="",p.path="",p.prefix="",p.protocol="",p.proxyBehavior="service",p.type="docker",!(jn.has(p.key)&&p.value==="true")&&x.push(p);for(const p of l)p.custom="",p.description="",p.secure=!1,p.shared=!1,p.required=!1;return{dockerArgs:wn(yn(x)),dockerEnvs:l,dockerImage:i,dockerCommand:d}}function vn({dockerArgs:t,dockerEnvs:o,dockerImage:s,dockerCommand:r}){if(t.length===0&&o.length===0&&!s)return"";const l=["docker run \\"],c=new Set(["--publish","--volume","--expose","--device","--mount","--label","--cap-add","--cap-drop","--add-host","--dns","--network-alias","--sysctl","--ulimit","--network"]);for(const i of t){const{key:d,value:u}=i;if(c.has(d))if(u==="true")l.push(` ${d} \\`);else{const x=/[\s"']/g.test(u)?`"${u}"`:u;l.push(` ${d} ${x} \\`)}else if(!l.some(x=>x.startsWith(` ${d}`)))if(u==="true")l.push(` ${d} \\`);else{const x=/[\s"']/g.test(u)?`"${u}"`:u;l.push(` ${d} ${x} \\`)}}for(const i of o){const{key:d,value:u}=i,x=/["']/g.test(u)?u:`"${u}"`;l.push(` -e ${d}=${x} \\`)}return s&&l.push(` ${s} \\`),r&&l.push(` ${r} \\`),l[l.length-1]?.endsWith(" \\")&&(l[l.length-1]=(l[l.length-1]||"").slice(0,-2)),l.join(`
194
194
  `)}const vs={"--volume":t=>{const[o]=t.split(":");return o?ws(t)&&!t.startsWith("$BLOCKLET_APP_DIR/")&&!t.startsWith("$BLOCKLET_DATA_DIR/")?"Volume must start with $BLOCKLET_APP_DIR or $BLOCKLET_DATA_DIR":t.indexOf("..")>-1?'Volume cannot contain ".."':"":"Volume must start with key:value"}},Qe=t=>t.replace(/^[-]+/,"").replace(/-([a-z])/g,(r,l)=>l.toUpperCase()),Cn=t=>`--${t.replace(/([A-Z])/g,"-$1").toLowerCase()}`,Rn=[" -- ","~","&","|",">","<","{","}","[","]",";","$","!","*","%","&&","||",","],Sn=["rm ","sudo "];function Cs(t){if(t==="")return;if(/(\n|\\n|\\\n|\t|\\t|\\\t)/.test(t))throw new Error("Docker CMD is invalid");const s=t.toLocaleLowerCase();if(Sn.some(l=>s.indexOf(l)!==-1))throw new Error("Docker CMD is invalid");if(Rn.some(l=>t.indexOf(l)!==-1))throw new Error("Docker CMD is invalid");if(!/^(?:(?:[a-zA-Z0-9\-_.\/:=\s]+)|(?:\@{1,2}[a-zA-Z_][a-zA-Z0-9_]*))+$/.test(t))throw new Error("Docker CMD is invalid")}const Tn=Array.from(new Set(Object.keys(Ut).map(Qe))),Dn=["publish","volume"];oe.object({workdir:oe.string().trim().optional(),image:oe.string().trim().regex(/^[^\s]+$/).optional(),shell:oe.string().trim().optional(),volumes:oe.array().items(oe.string().trim()).optional(),script:oe.string().trim().optional(),installNodeModules:oe.boolean().optional(),skipWrapDockerfile:oe.boolean().optional(),command:oe.string().allow("").default("").optional().custom((t,o)=>{try{return Cs(t),t}catch(s){return o.error("any.invalid",{message:s.message})}},"Docker CMD validation"),runBaseScript:oe.boolean().optional(),...Tn.reduce((t,o)=>{const s=vs[Cn(o)];return Dn.includes(o)?(t[o]=oe.array().items(oe.string().trim()).optional(),s?t[o]=oe.array().items(oe.string().trim().custom((r,l)=>{const c=s(r);return c?l.message(c):r})).optional():t[o]=oe.array().items(oe.string().trim()).optional(),t):(s?t[o]=oe.string().trim().custom((r,l)=>{const c=s(r);return c?l.message(c):r}).optional():t[o]=oe.string().trim().optional(),t)},{})}).optional();function Dt({index:t,item:o,dockerParams:s,setDockerParams:r,dataKey:l,t:c,readOnly:i}){const d=o?.value||"",[u,x]=k.useState(!1),p=()=>{s[l]?.splice(t,1),r({...s,[l]:[...s[l]]})},m=(P,A)=>{s[l]?.[t]&&(A?(s[l][t].custom=s[l][t].value,s[l][t].value=`$${Qe(o.key)}`):(s[l][t].value=s[l][t].custom||"",s[l][t].custom="")),r({...s,[l]:[...s[l]]})},f=(P,A)=>{const w=s[l][t]?.value||"";s[l][t]={...s[l][t],secure:A,value:A&&w===me.BLOCKLET_AUTOMATIC_ENV_VALUE?"":w},r({...s,[l]:[...s[l]]})},b=(P,A)=>{s[l][t]={...s[l][t],shared:A},r({...s,[l]:[...s[l]]})},h=(P,A)=>{const w=s[l][t]?.value||"";s[l][t]={...s[l][t],required:A,value:A&&w===me.BLOCKLET_AUTOMATIC_ENV_VALUE?"":w},r({...s,[l]:[...s[l]]})},j=(P,A)=>{s[l][t]={...s[l][t],value:A?me.BLOCKLET_AUTOMATIC_ENV_VALUE:"",secure:!1,required:!1},r({...s,[l]:[...s[l]]})},v=P=>{s[l][t]={...s[l][t],description:P.target.value},r({...s,[l]:[...s[l]]})},g=P=>{const A=P.target.value==="web"?"web":"docker";A==="web"&&s.dockerArgs.forEach(Z=>{Z.type="docker"});const S=`/${s.dockerImage.replace(/\W/g,"-")}-${t}`;s.dockerArgs[t]={...s.dockerArgs[t],type:A,path:A==="docker"?S:"/",protocol:"http",prefix:A==="docker"?S:"/",name:"publicUrl",port:"BLOCKLET_PORT"},r({...s,dockerArgs:[...s.dockerArgs]})},C=P=>{s.dockerArgs[t]={...s.dockerArgs[t],proxyBehavior:P.target.value==="direct"?"direct":"service"},r({...s,dockerArgs:[...s.dockerArgs]})},D=P=>{const A=P.target.value;s[l][t]={...s[l][t],prefix:A,path:A==="*"?"/":A},r({...s,[l]:[...s[l]]})},R=P=>{s[l]?.[t]&&(s[l][t].value=P.target.value),r({...s,[l]:[...s[l]]})},y=d===`$${Qe(o.key)}`||o.custom,T=l==="dockerArgs"&&!Ut[o.key],O=kn[o.key],N=l==="dockerEnvs",z=o.key==="--publish";let K=o.key;return z&&o.type==="web"?K="--publish (Web)":N&&(K=`--env ${o.key}`),e.jsxs(a,{sx:{display:"flex",flexDirection:"row",gap:2,alignItems:"center"},children:[e.jsx(a,{sx:{width:250},children:e.jsx($,{sx:{textOverflow:"ellipsis",width:"100%",overflow:"hidden"},children:K})}),e.jsxs(a,{sx:{display:"flex",flexDirection:"column",gap:1,flex:1},children:[e.jsx(ne,{disabled:i||y||T||o.value===me.BLOCKLET_AUTOMATIC_ENV_VALUE,placeholder:"",value:y?`$${Qe(o.key)}`:d,sx:{flex:1},error:T,onChange:R,slotProps:{input:{endAdornment:e.jsxs(Xe,{position:"end",sx:{zoom:.9},children:[(!(O||T)||N||z)&&e.jsx(ce,{onClick:()=>x(!0),children:e.jsx(ae,{icon:"icon-park-outline:setting-config"})}),!i&&e.jsx(ce,{onClick:p,color:T?"error":"default",children:e.jsx(ae,{icon:"ic:round-delete"})})]})}}}),T&&e.jsx($,{variant:"caption",color:"error",children:c("blocklet.publish.docker.noAllowTheArg")}),o.key==="--publish"&&e.jsx($,{variant:"caption",sx:{color:"text.secondary"},children:c("blocklet.publish.docker.publishTips")}),o.key==="--volume"&&vs[o.key](d)&&e.jsx($,{variant:"caption",color:"error",children:c("blocklet.publish.docker.volumeTips")})]}),u&&e.jsx(ct,{open:!0,fullWidth:!0,maxWidth:"sm",PaperProps:{style:{minHeight:0}},title:c(N?"blocklet.publish.docker.modifyEnv":"blocklet.publish.docker.modifyParam"),onClose:()=>x(!1),children:e.jsxs(a,{sx:{display:"flex",flexDirection:"column",gap:1,paddingBottom:2},children:[O||T||N?null:e.jsxs(a,{sx:{width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx($,{children:c("blocklet.publish.docker.needCustomInput")}),e.jsx(Le,{disabled:i,checked:y,onChange:m,sx:{zoom:.9}})]}),N&&e.jsxs(a,{sx:{width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx($,{children:c("blocklet.publish.docker.shared")}),e.jsx(Le,{disabled:i,checked:o.shared,onChange:b,sx:{zoom:.9}})]}),N&&e.jsxs(a,{sx:{width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx($,{children:c("blocklet.publish.docker.required")}),e.jsx(Le,{disabled:i,checked:o.required,onChange:h,sx:{zoom:.9}})]}),N&&e.jsxs(a,{sx:{width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx($,{children:c("blocklet.publish.docker.secure")}),e.jsx(Le,{disabled:i,checked:o.secure,onChange:f,sx:{zoom:.9}})]}),N&&e.jsxs(a,{sx:{width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx($,{children:c("blocklet.publish.docker.autoGenerated")}),e.jsx(Le,{disabled:i,checked:o.value===me.BLOCKLET_AUTOMATIC_ENV_VALUE,onChange:j,sx:{zoom:.9}})]}),N&&e.jsxs(a,{sx:{mt:1,width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx($,{sx:{flex:1},children:c("blocklet.publish.docker.description")}),e.jsx(ne,{disabled:i,value:o.description,onChange:v,sx:{flex:1},label:c("blocklet.publish.docker.description")})]}),z&&e.jsxs(a,{sx:{mt:1,width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx($,{sx:{flex:1},children:c("blocklet.publish.docker.portType")}),e.jsxs(vt,{value:o.type||"docker",onChange:g,children:[e.jsx(be,{value:"docker",children:"Docker"}),e.jsx(be,{value:"web",children:"Web"})]})]}),z&&o.type==="web"&&e.jsxs(a,{sx:{mt:1,width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx($,{sx:{flex:1},children:c("blocklet.publish.docker.proxyBehavior")}),e.jsxs(vt,{value:o.proxyBehavior||"service",onChange:C,children:[e.jsx(be,{value:"service",children:c("blocklet.publish.docker.serviceProxy")}),e.jsx(be,{value:"direct",children:c("blocklet.publish.docker.directProxy")})]})]}),z&&o.type==="web"&&e.jsxs(a,{sx:{mt:1,width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx($,{sx:{flex:1},children:c("blocklet.publish.docker.prefix")}),e.jsx(ne,{disabled:i,value:o.prefix,onChange:D,sx:{flex:1},label:c("blocklet.publish.docker.prefix")})]})]})})]})}Dt.propTypes={dockerParams:n.object.isRequired,setDockerParams:n.func.isRequired,dataKey:n.string.isRequired,item:n.object.isRequired,t:n.func.isRequired,readOnly:n.bool.isRequired,index:n.number.isRequired};const In=`
195
195
  docker run --name postgrest
196
196
  -p 3000:3000
@@ -1 +1 @@
1
- import{_ as r}from"./vendor-ux-sqP3hEhY.js";import{V as _,W as e}from"./index-CN4lpn74.js";const m={en:_(e),ar:()=>r(()=>import("./ar-BJZY7v5z.js"),[],import.meta.url).then(t=>_(t.default)),de:()=>r(()=>import("./de-BF0NHTXz.js"),[],import.meta.url).then(t=>_(t.default)),es:()=>r(()=>import("./es-Dv2m4LXp.js"),[],import.meta.url).then(t=>_(t.default)),fr:()=>r(()=>import("./fr-BGhg9oO3.js"),[],import.meta.url).then(t=>_(t.default)),hi:()=>r(()=>import("./hi-CPfDhW8g.js"),[],import.meta.url).then(t=>_(t.default)),id:()=>r(()=>import("./id-9TUzKF6k.js"),[],import.meta.url).then(t=>_(t.default)),ja:()=>r(()=>import("./ja-DT5bRsBF.js"),[],import.meta.url).then(t=>_(t.default)),ko:()=>r(()=>import("./ko-CJn9PyPz.js"),[],import.meta.url).then(t=>_(t.default)),pt:()=>r(()=>import("./pt-K9FK6Ube.js"),[],import.meta.url).then(t=>_(t.default)),ru:()=>r(()=>import("./ru-C_RwukUu.js"),[],import.meta.url).then(t=>_(t.default)),th:()=>r(()=>import("./th-Bhii_FfA.js"),[],import.meta.url).then(t=>_(t.default)),vi:()=>r(()=>import("./vi-DVF2tjOG.js"),[],import.meta.url).then(t=>_(t.default)),"zh-TW":()=>r(()=>import("./zh-tw-BdDE7n5E.js"),[],import.meta.url).then(t=>_(t.default)),zh:()=>r(()=>import("./zh-98nxdLeR.js"),[],import.meta.url).then(t=>_(t.default))};export{m as t};
1
+ import{_ as r}from"./vendor-ux-sqP3hEhY.js";import{V as _,W as e}from"./index-lFDZOk_k.js";const m={en:_(e),ar:()=>r(()=>import("./ar-BJZY7v5z.js"),[],import.meta.url).then(t=>_(t.default)),de:()=>r(()=>import("./de-BF0NHTXz.js"),[],import.meta.url).then(t=>_(t.default)),es:()=>r(()=>import("./es-Dv2m4LXp.js"),[],import.meta.url).then(t=>_(t.default)),fr:()=>r(()=>import("./fr-BGhg9oO3.js"),[],import.meta.url).then(t=>_(t.default)),hi:()=>r(()=>import("./hi-CPfDhW8g.js"),[],import.meta.url).then(t=>_(t.default)),id:()=>r(()=>import("./id-9TUzKF6k.js"),[],import.meta.url).then(t=>_(t.default)),ja:()=>r(()=>import("./ja-DT5bRsBF.js"),[],import.meta.url).then(t=>_(t.default)),ko:()=>r(()=>import("./ko-CJn9PyPz.js"),[],import.meta.url).then(t=>_(t.default)),pt:()=>r(()=>import("./pt-K9FK6Ube.js"),[],import.meta.url).then(t=>_(t.default)),ru:()=>r(()=>import("./ru-C_RwukUu.js"),[],import.meta.url).then(t=>_(t.default)),th:()=>r(()=>import("./th-Bhii_FfA.js"),[],import.meta.url).then(t=>_(t.default)),vi:()=>r(()=>import("./vi-DVF2tjOG.js"),[],import.meta.url).then(t=>_(t.default)),"zh-TW":()=>r(()=>import("./zh-tw-BdDE7n5E.js"),[],import.meta.url).then(t=>_(t.default)),zh:()=>r(()=>import("./zh-98nxdLeR.js"),[],import.meta.url).then(t=>_(t.default))};export{m as t};
@@ -1,4 +1,4 @@
1
- import{j as t,a6 as f,ak as r,at as j,W as n}from"./vendor-mui-core-DHT36AZL.js";import{r as h}from"./vendor-react-CUXIiAnY.js";import{p as S,n as p}from"./vendor-ux-sqP3hEhY.js";import{a as C}from"./page-header-B4MDj6gy.js";import{ac as g}from"./index-CN4lpn74.js";import{o as b}from"./vendor-arcblock-3xKfH3F1.js";import{u as k}from"./config-space-BSBup5aB.js";import{C as y,D as v,a as w}from"./connect-to-B-qzDPba.js";import{S as c}from"./step-actions-DbAALRbw.js";import{S as E}from"./layout-CkQwn0NR.js";import"./vendor-utils-BSZ4yJws.js";import"./vendor-hooks-fhL5FJET.js";import"./lottie-web-4koyQiv_.js";import"./spaces-B9YyAxJd.js";import"./api-DIucIOLX.js";import"./index-DQB7DBpQ.js";import"./index-DRYJ0xIl.js";import"./index-BojVbZw0.js";import"./index-bbu7QFpz.js";import"./index-DBs9Ljax.js";import"./use-mobile-BpPz1bKz.js";import"./content-layout-RghQFMLL.js";function T({onNext:a=()=>{},onPrevious:d=()=>{}}){const{t:e}=h.useContext(S),{blocklet:o}=g(),{spaceGateway:m,settingStorageEndpoint:l,updateSpaceGateway:u,hasStorageEndpoint:x,loading:i,storageEndpoint:s}=k();return i?t.jsx(b,{relative:"parent",children:t.jsx(f,{})}):t.jsxs(B,{children:[t.jsx("div",{className:"header",children:t.jsx(C,{title:e("setup.didSpace.title"),subTitle:e("setup.didSpace.subTitle"),onClickBack:d})}),t.jsxs(r,{className:"form-container",sx:{width:"100%",maxWidth:"720px"},children:[x?t.jsx(y,{spaceGateway:m,settingStorageEndpoint:l}):t.jsx(v,{}),o?.capabilities?.didSpace&&t.jsx(r,{sx:{display:"flex",alignItems:"center",justifyContent:"center",paddingTop:"24px"},children:t.jsx(w,{onConnect:u,storageEndpoint:s})})]}),o?.capabilities?.didSpace==="required"&&t.jsx(c,{mt:8,children:t.jsx(p,{loading:i,variant:"contained",disabled:i||!s,onClick:()=>a(),children:e("setup.continue")})}),o?.capabilities?.didSpace==="optional"&&t.jsx(c,{blocklet:o,onStartNow:()=>a("complete"),children:t.jsx(p,{className:"start-now",loading:i,variant:"contained",disabled:i,onClick:()=>a(),children:e(s?"setup.continue":"setup.skip")})})]})}T.propTypes={onNext:n.func,onPrevious:n.func};const B=j(E)`
1
+ import{j as t,a6 as f,ak as r,at as j,W as n}from"./vendor-mui-core-DHT36AZL.js";import{r as h}from"./vendor-react-CUXIiAnY.js";import{p as S,n as p}from"./vendor-ux-sqP3hEhY.js";import{a as C}from"./page-header-B4MDj6gy.js";import{ac as g}from"./index-lFDZOk_k.js";import{o as b}from"./vendor-arcblock-3xKfH3F1.js";import{u as k}from"./config-space-B6ikfnoY.js";import{C as y,D as v,a as w}from"./connect-to-D3Fxg-mH.js";import{S as c}from"./step-actions-tRQyAl6A.js";import{S as E}from"./layout-0zU7a-3v.js";import"./vendor-utils-BSZ4yJws.js";import"./vendor-hooks-fhL5FJET.js";import"./lottie-web-4koyQiv_.js";import"./spaces-C_pXJSzm.js";import"./api-DIucIOLX.js";import"./index-CxJOg5jI.js";import"./index-DRYJ0xIl.js";import"./index-BojVbZw0.js";import"./index-bbu7QFpz.js";import"./index-DBs9Ljax.js";import"./use-mobile-BpPz1bKz.js";import"./content-layout-RghQFMLL.js";function T({onNext:a=()=>{},onPrevious:d=()=>{}}){const{t:e}=h.useContext(S),{blocklet:o}=g(),{spaceGateway:m,settingStorageEndpoint:l,updateSpaceGateway:u,hasStorageEndpoint:x,loading:i,storageEndpoint:s}=k();return i?t.jsx(b,{relative:"parent",children:t.jsx(f,{})}):t.jsxs(B,{children:[t.jsx("div",{className:"header",children:t.jsx(C,{title:e("setup.didSpace.title"),subTitle:e("setup.didSpace.subTitle"),onClickBack:d})}),t.jsxs(r,{className:"form-container",sx:{width:"100%",maxWidth:"720px"},children:[x?t.jsx(y,{spaceGateway:m,settingStorageEndpoint:l}):t.jsx(v,{}),o?.capabilities?.didSpace&&t.jsx(r,{sx:{display:"flex",alignItems:"center",justifyContent:"center",paddingTop:"24px"},children:t.jsx(w,{onConnect:u,storageEndpoint:s})})]}),o?.capabilities?.didSpace==="required"&&t.jsx(c,{mt:8,children:t.jsx(p,{loading:i,variant:"contained",disabled:i||!s,onClick:()=>a(),children:e("setup.continue")})}),o?.capabilities?.didSpace==="optional"&&t.jsx(c,{blocklet:o,onStartNow:()=>a("complete"),children:t.jsx(p,{className:"start-now",loading:i,variant:"contained",disabled:i,onClick:()=>a(),children:e(s?"setup.continue":"setup.skip")})})]})}T.propTypes={onNext:n.func,onPrevious:n.func};const B=j(E)`
2
2
  height: 100%;
3
3
  overflow-y: auto;
4
4
  `;export{T as default};
@@ -1,4 +1,4 @@
1
- import{r as v,g as $e,a as qe}from"./vendor-react-CUXIiAnY.js";import{g as Ue,k as Z}from"./vendor-hooks-fhL5FJET.js";import{j as e,ak as t,at as $,b1 as Y,a6 as B,aX as He,am as G,cp as Ge,U as Ye,T as F,a3 as Ke,W as S,z as O,M as Q,I as _,cq as ge,cb as je,A as Ve,x as Ze,c3 as Qe,c4 as ee,bw as Xe,F as Je,bc as es,s as ss}from"./vendor-mui-core-DHT36AZL.js";import{V as A,b as W,j as ts,h as ae,z as se,H as P,n as z,i as re,P as ye,x as ve,Q as as,a2 as rs}from"./vendor-ux-sqP3hEhY.js";import{_ as D,o as os,a1 as be,c as M,B as J,ac as ns,e as is,Y as ls,a2 as V,b5 as cs}from"./index-CN4lpn74.js";import{W as oe}from"./did-address-CihvGtuj.js";import{u as N}from"./team-BnNEVFdE.js";import{a as ne,r as ie,b as le,c as Se,d as X,e as ds,u as ps,f as us}from"./passport-item-BMa8rd85.js";import{p as Ce}from"./util-DzwOLYt5.js";import{u as ms}from"./use-mobile-DoKVMODs.js";import{v as H}from"./index-bbu7QFpz.js";import{w as q,P as fs}from"./permission-DLnMVuoy.js";import{C as xs}from"./Google-PoHjNVzr.js";import{c as hs}from"./create-passport-svg-BZVXsAoP.js";import{A as gs}from"./vendor-arcblock-3xKfH3F1.js";import{G as K,_ as js}from"./vendor-utils-BSZ4yJws.js";import{e as we}from"./edit.svg-Dz9cVo7r.js";import{H as ce,P as ys}from"./index-C0TbDTja.js";import{C as Te}from"./confirm-DPD7yjeR.js";import{L as Ie}from"./list-header-CA-QkwGq.js";import{f as te}from"./index-DBs9Ljax.js";import{u as vs}from"./useSetState-cWrp7qoX.js";import"./lottie-web-4koyQiv_.js";import"./session-DNlfWI2Z.js";import"./isURL-DskT4RKm.js";import"./use-app-logo-BWOYOuhG.js";import"./ua-parser-DP5omx3I.js";import"./base32-AX-I0UaR.js";import"./cloneDeep-B7kH4W7U.js";import"./lock.svg-BPCZ0CT3.js";const me="info";function Pe({createPassportSvg:c,passport:s,onCancel:p,onSwitchPassport:u=()=>{}}){const{t:f}=A(),i=Ue({tab:me}),d={info:{label:f("common.basicInfo"),value:me,component:()=>e.jsx(De,{passport:s,createPassportSvg:c})},logs:{label:f("common.logs"),value:"logs",component:()=>e.jsx(Ae,{passport:s})},related:{label:f("team.passport.related"),value:"related",component:()=>e.jsx(Le,{passport:s,onSwitchPassport:u})}},l=Object.values(d).map(({label:h,value:m})=>({label:h,value:m})).filter(h=>h.value==="related"?s.parentDid:!0),r=d[i.tab]||d.info,n=h=>{i.tab=h};return e.jsx(W,{title:f("common.passport"),onClose:p,open:!0,PaperProps:{style:{maxWidth:800,minHeight:"80vh"}},fullWidth:!0,children:e.jsxs(bs,{children:[e.jsx(t,{className:"tabs",children:e.jsx(ts,{tabs:l,current:i.tab,onChange:n,scrollButtons:"auto"})}),e.jsx(t,{className:"body",children:e.jsx(r.component,{})})]})})}Pe.propTypes={createPassportSvg:S.func.isRequired,passport:S.object.isRequired,onCancel:S.func.isRequired,onSwitchPassport:S.func};const bs=$(t)`
1
+ import{r as v,g as $e,a as qe}from"./vendor-react-CUXIiAnY.js";import{g as Ue,k as Z}from"./vendor-hooks-fhL5FJET.js";import{j as e,ak as t,at as $,b1 as Y,a6 as B,aX as He,am as G,cp as Ge,U as Ye,T as F,a3 as Ke,W as S,z as O,M as Q,I as _,cq as ge,cb as je,A as Ve,x as Ze,c3 as Qe,c4 as ee,bw as Xe,F as Je,bc as es,s as ss}from"./vendor-mui-core-DHT36AZL.js";import{V as A,b as W,j as ts,h as ae,z as se,H as P,n as z,i as re,P as ye,x as ve,Q as as,a2 as rs}from"./vendor-ux-sqP3hEhY.js";import{_ as D,o as os,a1 as be,c as M,B as J,ac as ns,e as is,Y as ls,a2 as V,b5 as cs}from"./index-lFDZOk_k.js";import{W as oe}from"./did-address-CihvGtuj.js";import{u as N}from"./team-KWOyNaWn.js";import{a as ne,r as ie,b as le,c as Se,d as X,e as ds,u as ps,f as us}from"./passport-item-BkmVlAdr.js";import{p as Ce}from"./util-MbDHkO8z.js";import{u as ms}from"./use-mobile-DoKVMODs.js";import{v as H}from"./index-bbu7QFpz.js";import{w as q,P as fs}from"./permission-B3_OQqtH.js";import{C as xs}from"./Google-PoHjNVzr.js";import{c as hs}from"./create-passport-svg-BZVXsAoP.js";import{A as gs}from"./vendor-arcblock-3xKfH3F1.js";import{G as K,_ as js}from"./vendor-utils-BSZ4yJws.js";import{e as we}from"./edit.svg-Dz9cVo7r.js";import{H as ce,P as ys}from"./index-D6MFQa2J.js";import{C as Te}from"./confirm-Dge1BR0a.js";import{L as Ie}from"./list-header-CA-QkwGq.js";import{f as te}from"./index-DBs9Ljax.js";import{u as vs}from"./useSetState-cWrp7qoX.js";import"./lottie-web-4koyQiv_.js";import"./session-DR7jqIW5.js";import"./isURL-fcz3vuMN.js";import"./use-app-logo-hGlkw2d_.js";import"./ua-parser-DP5omx3I.js";import"./base32-AX-I0UaR.js";import"./cloneDeep-B7kH4W7U.js";import"./lock.svg-BPCZ0CT3.js";const me="info";function Pe({createPassportSvg:c,passport:s,onCancel:p,onSwitchPassport:u=()=>{}}){const{t:f}=A(),i=Ue({tab:me}),d={info:{label:f("common.basicInfo"),value:me,component:()=>e.jsx(De,{passport:s,createPassportSvg:c})},logs:{label:f("common.logs"),value:"logs",component:()=>e.jsx(Ae,{passport:s})},related:{label:f("team.passport.related"),value:"related",component:()=>e.jsx(Le,{passport:s,onSwitchPassport:u})}},l=Object.values(d).map(({label:h,value:m})=>({label:h,value:m})).filter(h=>h.value==="related"?s.parentDid:!0),r=d[i.tab]||d.info,n=h=>{i.tab=h};return e.jsx(W,{title:f("common.passport"),onClose:p,open:!0,PaperProps:{style:{maxWidth:800,minHeight:"80vh"}},fullWidth:!0,children:e.jsxs(bs,{children:[e.jsx(t,{className:"tabs",children:e.jsx(ts,{tabs:l,current:i.tab,onChange:n,scrollButtons:"auto"})}),e.jsx(t,{className:"body",children:e.jsx(r.component,{})})]})})}Pe.propTypes={createPassportSvg:S.func.isRequired,passport:S.object.isRequired,onCancel:S.func.isRequired,onSwitchPassport:S.func};const bs=$(t)`
2
2
  margin-top: -16px;
3
3
 
4
4
  .tabs {
@@ -1,4 +1,4 @@
1
- import{V as L,H as q,U as N,k as Y,i as Se,h as Te,a2 as Ie}from"./vendor-ux-sqP3hEhY.js";import{q as Re,k as ae,t as We}from"./vendor-hooks-fhL5FJET.js";import{r as v,a as ce}from"./vendor-react-CUXIiAnY.js";import{D as ze,J as de,j as e,Y as De,bC as Oe,$ as $e,ak as d,z as ne,T as S,a6 as F,aX as te,R as Ae,Q as H,b6 as ie,am as P,bf as _,a5 as J,V as G,S as Z,b4 as Pe,U as B,I as M,cj as qe,bh as Be,a7 as Le,F as Me,W as o,b1 as W,a3 as pe,c2 as ee,ck as Fe,aO as He,aP as Ne,cl as Ue,cm as _e,cn as Ve,s as oe,aU as Ke,aj as Ye,co as Je,aZ as Qe,cc as Xe,bb as Ge,cb as Ze}from"./vendor-mui-core-DHT36AZL.js";import{_ as V,c as ue,a1 as et,ac as tt,b4 as Q,ar as xe,as as he,at as me}from"./index-CN4lpn74.js";import{u as K}from"./team-BnNEVFdE.js";import{u as ot}from"./use-mobile-DoKVMODs.js";import{u as st,C as X}from"./index.esm-DTmS4tth.js";import{C as ge,a as be,J as nt}from"./vendor-utils-BSZ4yJws.js";import{C as it}from"./confirm-DPD7yjeR.js";import{A as rt}from"./actions-CIp6hu8_.js";import{T as re}from"./table-tips-cVuoMOXE.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-3xKfH3F1.js";import"./session-DNlfWI2Z.js";import"./isURL-DskT4RKm.js";import"./use-app-logo-BWOYOuhG.js";import"./index-DBs9Ljax.js";const lt=n=>{const[p,c]=v.useState(null),[f,r]=v.useState(!0),[w,u]=v.useState(null),j=window.blocklet?.appUrl,a=v.useMemo(()=>{const g={};return p&&(p.sources.forEach(y=>{g[y.did]={source:y,events:[],count:0}}),p.events.forEach(y=>{g[y.source]&&(g[y.source].events.push(y),g[y.source].count+=1)})),g},[p]),b=async()=>{try{if(r(!0),!j)return;const y=await(await fetch(ge(j,ue.WELLKNOWN_SERVICE_PATH_PREFIX,"/openevent.json"))).json();c(y),u(null)}catch(g){u(g instanceof Error?g:new Error(String(g)))}finally{r(!1)}};return v.useEffect(()=>{b()},[j]),{openEvent:p,setOpenEvent:c,eventsBySource:a,loading:f,error:w,loadData:b}};function fe({eventsBySource:n,selectedEvents:p,setSelectedEvents:c,error:f=null}){const{t:r}=L(),[w,u]=v.useState({}),j=v.useMemo(()=>{const s={};return Object.entries(n).forEach(([l,{events:m}])=>{const k=m.filter(T=>p[`${T.type}-${T.source}`]).length;s[l]=k}),s},[n,p]),a=v.useMemo(()=>Object.values(j).reduce((s,l)=>s+l,0),[j]),b=v.useMemo(()=>Object.values(n).reduce((s,{events:l})=>s+l.length,0),[n]),g=(s,l)=>{l.stopPropagation(),u({...w,[s]:!w[s]})},y=s=>{const l=`${s.type}-${s.source}`;c(m=>({...m,[l]:!m[l]}))},z=(s,l)=>{const m={};s.forEach(k=>{const T=`${k.type}-${k.source}`;m[T]=!l}),c(k=>({...k,...m}))},I=s=>{const l={};Object.values(n).forEach(({events:m})=>{m.forEach(k=>{const T=`${k.type}-${k.source}`;l[T]=s.target.checked})}),c(l)};return e.jsxs(d,{sx:{width:"100%"},children:[e.jsxs(d,{sx:{display:"flex",alignItems:"center",mb:1,mt:1},children:[e.jsx(ie,{control:e.jsx(J,{onChange:I,checked:a>0&&a===b}),label:e.jsxs(d,{sx:{display:"flex",alignItems:"center",cursor:"pointer"},children:[r("webhookEndpoint.selectAllEvents"),e.jsx(d,{sx:{display:"flex",alignItems:"center"},children:e.jsx(P,{title:r("webhookEndpoint.selectAllEventsTooltip"),placement:"right",children:e.jsx(_,{fontSize:"small",sx:{ml:.5,cursor:"help"}})})})]}),sx:{m:0}}),a>0&&e.jsx(S,{variant:"body2",color:"primary",sx:{ml:"auto"},children:r("webhookEndpoint.selectedEventsCount",{count:a})})]}),e.jsx(d,{className:"webhook-event-selector",sx:{maxHeight:"50vh",overflowY:"auto",overflowX:"hidden"},children:e.jsx(G,{disablePadding:!0,sx:{border:"1px solid",borderColor:"divider",borderRadius:.5},children:Object.entries(n).map(([s,{source:l,events:m,count:k}],T)=>{const O=j[s]>0,R=j[s]===m.length&&m.length>0,$=w[s];return e.jsxs(ce.Fragment,{children:[e.jsx(Z,{sx:{borderBottom:({palette:i})=>T<Object.keys(n).length-1?`1px solid ${i.divider}`:"none",px:0,py:1,"&:hover":{bgcolor:"rgba(0, 0, 0, 0.02)"}},children:e.jsxs(d,{sx:{display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center"},onClick:i=>{i.target.closest(".MuiFormControlLabel-root")||g(s,i)},children:[e.jsx(d,{sx:{display:"flex",alignItems:"center"},children:m.length>0&&e.jsx(ie,{control:e.jsx(J,{checked:R,indeterminate:O&&!R,onChange:i=>{i.stopPropagation(),z(m,R)}}),label:e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:1},children:[l.logo&&e.jsx(Pe,{src:l.logo,sx:{width:24,height:24}}),e.jsx(d,{children:l.title||s}),O&&e.jsx(B,{label:r("webhookEndpoint.selectedCount",{count:j[s]}),size:"small",sx:{mt:"2px",height:"20px",fontSize:"12px",bgcolor:i=>`${i.palette.primary.main}20`,color:"primary.main",fontWeight:500}})]}),sx:{m:0,"& .MuiFormControlLabel-label":{flex:1}}})}),e.jsxs(d,{sx:{display:"flex",alignItems:"center"},children:[e.jsx(S,{variant:"body2",sx:{color:"text.secondary",mr:1},children:r("webhookEndpoint.eventsCount",{count:k})}),m.length>0&&e.jsx(M,{size:"small",edge:"end",children:$?e.jsx(qe,{}):e.jsx(Be,{})})]})]})}),m.length>0&&e.jsx(Le,{in:$,timeout:"auto",unmountOnExit:!0,children:e.jsx(G,{disablePadding:!0,sx:{p:0,bgcolor:"rgba(0, 0, 0, 0.01)"},children:m.map(i=>{const x=`${i.type}-${i.source}`,t=!!p[x];return e.jsx(Z,{dense:!0,sx:{py:.75,px:1},onClick:()=>y(i),children:e.jsxs(d,{sx:{display:"flex",alignItems:"flex-start",width:"100%"},children:[e.jsx(J,{checked:t,sx:{flexShrink:0}}),e.jsxs(d,{sx:{flex:1,minWidth:0},children:[e.jsx(S,{variant:"body1",className:"webhook-event-type",sx:{cursor:"pointer",color:"text.primary",wordBreak:"break-word",overflowWrap:"break-word"},children:i.type}),e.jsx(S,{variant:"caption",sx:{color:"text.secondary",display:"block",cursor:"pointer",wordBreak:"break-word",overflowWrap:"break-word"},children:i.description})]})]})},x)})})})]},s)})})}),f&&e.jsx(Me,{error:!0,sx:{mt:1},children:f})]})}fe.propTypes={eventsBySource:o.objectOf(o.shape({source:o.shape({did:o.string.isRequired,title:o.string,description:o.string,version:o.string,logo:o.string}).isRequired,events:o.arrayOf(o.shape({type:o.string.isRequired,description:o.string.isRequired,source:o.string.isRequired})).isRequired,count:o.number.isRequired})).isRequired,selectedEvents:o.objectOf(o.bool).isRequired,setSelectedEvents:o.func.isRequired,error:o.string};function je({id:n=null,url:p="",description:c="",enabledEvents:f=[],onSubmit:r,onClose:w=()=>{}}){const{t:u}=L(),[j,a]=v.useState({}),{teamDid:b}=K(),{api:g}=V(),{loading:y,error:z,eventsBySource:I}=lt(),s=ze(),{control:l,handleSubmit:m,formState:{errors:k},reset:T,setValue:O,trigger:R}=st({defaultValues:{url:"",description:""}}),$=de(s.breakpoints.down("md"));v.useEffect(()=>{const t=Object.values(j).some(h=>h);O("selectedEvents",t?"valid":""),R("selectedEvents")},[j,O,R]);const i=()=>{a({}),T(),w()},x=async t=>{const h=Object.keys(j).filter(C=>j[C]),E={url:t.url,description:t.description,enabledEvents:h.map(C=>{const[D,se]=C.split("-");return!D||!se?null:{type:D,source:se}}).filter(Boolean)};try{if(n){const C=await g.updateWebhookEndpoint({input:{teamDid:b,id:n,data:E}});q.success(`${u("webhookEndpoint.updateWebhook")} ${u("webhookEndpoint.success")}`),r(C)}else{const C=await g.createWebhookEndpoint({input:{teamDid:b,input:E}});q.success(`${u("webhookEndpoint.createWebhook")} ${u("webhookEndpoint.success")}`),r(C)}}catch(C){q.error(C?.message)}i()};return v.useEffect(()=>{T({url:p,description:c}),a(f.reduce((t,h)=>(t[`${h.type}-${h.source}`]=!0,t),{}))},[T,a,p,c,f]),e.jsx(De,{open:!0,onClose:i,maxWidth:"lg",fullWidth:!0,fullScreen:$,sx:{"& .MuiDialog-paper":{minHeight:600}},children:e.jsxs("form",{onSubmit:m(x),children:[e.jsx(Oe,{children:u(n?"webhookEndpoint.editWebhookTitle":"webhookEndpoint.createWebhookTitle")}),e.jsx($e,{children:e.jsxs(d,{sx:{display:"flex",flexDirection:"column",gap:2,mt:2},children:[e.jsx(X,{name:"url",control:l,rules:{required:u("webhookEndpoint.validation.urlRequired"),pattern:{value:/^(http|https):\/\/[^ "]+$/,message:u("webhookEndpoint.validation.urlInvalid")}},render:({field:t})=>e.jsx(ne,{...t,label:u("webhookEndpoint.url.label"),fullWidth:!0,error:!!k.url,helperText:k.url?.message})}),e.jsx(X,{name:"description",control:l,rules:{required:u("webhookEndpoint.validation.descriptionRequired")},render:({field:t})=>e.jsx(ne,{...t,label:u("webhookEndpoint.description.label"),fullWidth:!0,multiline:!0,minRows:2,maxRows:4,error:!!k.description,helperText:k.description?.message})}),e.jsx(X,{name:"selectedEvents",control:l,rules:{required:u("webhookEndpoint.validation.eventRequired")},render:({field:t})=>e.jsx("input",{type:"hidden",...t})}),!y&&I&&Object.keys(I).length>0&&e.jsx(fe,{eventsBySource:I,selectedEvents:j,setSelectedEvents:a,error:k.selectedEvents?.message}),!y&&(!I||Object.keys(I).length===0)&&e.jsx(S,{sx:{color:"text.secondary"},children:u("webhookEndpoint.noAvailableEvents")}),y&&e.jsx(d,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"500px",width:"100%"},children:e.jsx(F,{size:20})}),z&&e.jsx(te,{severity:"error",children:u("webhookEndpoint.loadingError",{message:z?.message})})]})}),e.jsxs(Ae,{sx:{p:"8px 24px 24px"},children:[e.jsx(H,{onClick:i,children:u("common.cancel")}),e.jsx(H,{type:"submit",variant:"contained",color:"primary",children:u(n?"webhookEndpoint.updateWebhook":"webhookEndpoint.saveWebhook")})]})]})})}je.propTypes={onSubmit:o.func.isRequired,id:o.string,url:o.string,description:o.string,enabledEvents:o.arrayOf(o.shape({type:o.string.isRequired,source:o.string.isRequired})),onClose:o.func};function ye(n){switch(n){case"enabled":return"success";case"disabled":default:return"default"}}const at=(n="en")=>n==="tw"?"zh":n;function U(n,p="YYYY-MM-DD HH:mm:ss",c="en"){return n?et(n).locale(at(c)).format(p):"-"}function ct(n){return typeof n=="number"?!1:be(n)}function dt(n){return n>=200&&n<300}function A({value:n,label:p,tip:c="",divider:f=!1}){const r=ct(n);return e.jsxs(e.Fragment,{children:[e.jsxs(W,{direction:"column",alignItems:"flex-start",children:[e.jsxs(S,{component:"div",variant:"body1",mb:1,color:"text.primary",sx:{fontWeight:500},children:[p,!!c&&e.jsx(P,{title:c,children:e.jsx(_,{fontSize:"small"})})]}),e.jsx(S,{component:"div",variant:"body1",color:r?"text.disabled":"text.secondary",sx:{width:"100%",minHeight:"24px"},children:r?"-":n})]}),f&&e.jsx(pe,{orientation:"vertical",flexItem:!0})]})}A.propTypes={label:o.oneOfType([o.string,o.node]).isRequired,value:o.oneOfType([o.string,o.node]).isRequired,tip:o.oneOfType([o.string,o.node]),divider:o.bool};function we({title:n,children:p=null,mb:c=1.5,mt:f=1.5}){return e.jsxs(W,{className:"section-header",direction:"row",sx:{justifyContent:"space-between",alignItems:"center",flexWrap:"wrap",gap:1,mb:c,mt:f,pb:1},children:[e.jsx(S,{variant:"h3",sx:{fontSize:{xs:"18px",md:"1.09375rem"}},component:"div",children:n}),p]})}we.propTypes={title:o.oneOfType([o.string,o.node]).isRequired,children:o.node,mb:o.number,mt:o.number};const pt={width:24,height:24,body:'<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20 11A8.1 8.1 0 0 0 4.5 9M4 5v4h4m-4 4a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4"/>'},ut=n=>{const p={};return n.forEach(c=>{const f=new Date(c.createdAt).toLocaleDateString();p[f]||(p[f]=[]),p[f]?.push(c)}),p};function ke({eventId:n="",webhookEndpointId:p="",event:c=null}){const{api:f,ws:{useSubscription:r}}=V(),{t:w}=L(),{teamDid:u}=K(),{blocklet:j}=tt(),{data:a,loadMore:b,loadingMore:g,loading:y,mutate:z}=Re(t=>{const E=t?Math.ceil(t.list.length/15)+1:1;return f.getWebhookAttempts({input:{teamDid:u,input:{eventId:n,webhookId:p},paging:{page:E,pageSize:15}}})},{reloadDeps:[n,p]}),I=a?.list||[],[s,l]=v.useState(null),[m,k]=v.useState(!1),T=ut(I);if(v.useEffect(()=>{!s&&a?.list.length&&l(a.list[0])},[a?.list.length,s]),r(ue.EVENTS.WEBHOOK_ATTEMPT,t=>{z(h=>{if(h.list.find(C=>C.id===t.id)){const C=h.list.map(D=>D.id===t.id?{...D,...t}:D);return{...h,list:C}}return t.endpoint=h.list[0]?.endpoint,t.event=h.list[0]?.event,{...h,list:[t,...h.list]}})},[]),y)return e.jsx(F,{});const O=a&&a.list.length<a.paging.total,R=async()=>{s&&(k(!0),await f.retryWebhookAttempt({input:{teamDid:u,eventId:s.event.id,webhookId:p,attemptId:s.id}}).finally(()=>{setTimeout(()=>{k(!1)},1e3)}))},$=t=>{if(t.responseBody&&t.responseBody?.sessionId&&t.responseBody?.projectId&&t.responseBody?.agentId){const h=j?.site?.domainAliases[0]?.value,E=(j.children||[]).find(D=>D?.meta?.name==="ai-studio"),C=nt(ge(`https://${h}`,E?.mountPoint||"","projects",t.responseBody.projectId,"logs/main"),{sessionId:t.responseBody.sessionId,agentId:t.responseBody.agentId});return e.jsx(M,{sx:{fontSize:20},onClick:()=>window.open(C,"_blank"),children:e.jsx(d,{component:N,icon:Q})})}return null},i=t=>t.status==="pending"?e.jsx(Ue,{color:"warning"}):dt(t.responseStatus)?e.jsx(_e,{color:"success"}):e.jsx(Ve,{color:"error"}),x=s?.triggeredFrom&&(a?.list||[]).find(t=>t.id===s.triggeredFrom);return e.jsxs(xt,{container:!0,spacing:{xs:0,md:1},sx:{height:1},children:[e.jsx(ee,{size:{xs:12,md:4},sx:{height:1},children:be(Object.keys(T))?e.jsx(S,{sx:{color:"text.secondary"},children:w("webhookEndpoint.waitingForEvents")}):e.jsxs(e.Fragment,{children:[e.jsx(G,{sx:{maxHeight:"calc(100% - 40px)",py:0,overflowY:"auto"},children:Object.entries(T).map(([t,h])=>e.jsxs(ce.Fragment,{children:[e.jsx(Fe,{sx:{p:0},children:t}),h.map(E=>e.jsxs(Z,{sx:{cursor:"pointer",px:1},onClick:()=>l(E),selected:s&&s?.id===E?.id,secondaryAction:e.jsx(S,{sx:{color:"text.secondary"},children:U(E.createdAt,"HH:mm:ss")}),children:[e.jsx(He,{sx:{minWidth:0,mr:1.5},children:i(E)}),e.jsx(Ne,{primary:e.jsx(S,{sx:{color:"text.primary"},children:E.event.type})})]},E.id))]},t))}),O&&e.jsx(d,{sx:{display:"flex",justifyContent:"center",alignItems:"center",width:1},children:e.jsx(H,{variant:"text",type:"button",color:"inherit",onClick:b,disabled:g,sx:{color:t=>t.palette.text.disabled},children:w(g?"webhookEndpoint.loadingMore":"webhookEndpoint.loadMore")})})]})}),e.jsxs(ee,{size:{xs:12,md:8},sx:{height:1},children:[s&&e.jsxs(W,{direction:"column",spacing:2,sx:{height:1,overflow:"auto",pl:{xs:0,md:1},mt:{xs:2,md:0},borderLeft:{xs:"none"}},children:[e.jsxs(d,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(S,{variant:"h4",children:w(`common.${s.status}`)}),e.jsx(d,{children:$(s)})]}),e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:1},children:[x&&e.jsx(P,{placement:"left",title:e.jsxs(W,{onClick:()=>l(x),sx:{gap:1,cursor:"pointer",".did-address-text":{color:"common.white"}},children:[e.jsx(xe,{showDid:!0,did:s.triggeredBy,cardType:me.Detailed,infoType:he.Minimal,sx:{border:0,padding:0,minWidth:0,".MuiTypography-root":{color:"common.white",fontWeight:400}}}),e.jsx(pe,{}),e.jsxs(d,{sx:{display:"flex",flexDirection:"column"},children:[e.jsx(S,{variant:"body2",sx:{color:"primary.main"},children:w("webhookEndpoint.triggeredFrom")}),e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(S,{variant:"body2",children:s.id}),e.jsx(M,{onClick:()=>l(x),children:e.jsx(d,{component:N,icon:Q,sx:{fontSize:16,color:"common.white"}})})]})]})]}),slotProps:{tooltip:{sx:{maxWidth:400}}},children:e.jsx(M,{onClick:()=>l(x),children:e.jsx(d,{component:N,icon:Q,sx:{fontSize:16}})})}),e.jsxs(H,{variant:"outlined",color:"primary",size:"small",onClick:R,disabled:m,children:[e.jsx(d,{component:N,icon:pt,sx:{fontSize:16,animation:m?"spin 1s linear infinite":"none",mr:.5}}),w("notification.resend")]})]})]}),e.jsxs(d,{children:[e.jsxs(S,{variant:"h6",children:[w("webhookEndpoint.response")," (",s.responseStatus,")"]}),e.jsx(Y,{language:"json",children:JSON.stringify(s.responseBody,null,2)})]}),e.jsxs(d,{children:[e.jsx(W,{direction:"row",spacing:1,sx:{alignItems:"center"},children:e.jsx(S,{variant:"h6",children:w("webhookEndpoint.request")})}),e.jsx(Y,{language:"json",sx:{margin:0},children:JSON.stringify(s.event,null,2)})]})]}),a?.list.length===0&&c&&e.jsxs(d,{children:[e.jsx(W,{direction:"row",spacing:1,sx:{alignItems:"center"},children:e.jsx(S,{variant:"h6",children:w("webhookEndpoint.eventData")})}),e.jsx(Y,{language:"json",sx:{margin:0},children:JSON.stringify(c.data,null,2)})]})]})]})}ke.propTypes={eventId:o.string,webhookEndpointId:o.string,event:o.shape({type:o.string,data:o.object,request:o.object,requestInfo:o.object})};const xt=oe(ee)`
1
+ import{V as L,H as q,U as N,k as Y,i as Se,h as Te,a2 as Ie}from"./vendor-ux-sqP3hEhY.js";import{q as Re,k as ae,t as We}from"./vendor-hooks-fhL5FJET.js";import{r as v,a as ce}from"./vendor-react-CUXIiAnY.js";import{D as ze,J as de,j as e,Y as De,bC as Oe,$ as $e,ak as d,z as ne,T as S,a6 as F,aX as te,R as Ae,Q as H,b6 as ie,am as P,bf as _,a5 as J,V as G,S as Z,b4 as Pe,U as B,I as M,cj as qe,bh as Be,a7 as Le,F as Me,W as o,b1 as W,a3 as pe,c2 as ee,ck as Fe,aO as He,aP as Ne,cl as Ue,cm as _e,cn as Ve,s as oe,aU as Ke,aj as Ye,co as Je,aZ as Qe,cc as Xe,bb as Ge,cb as Ze}from"./vendor-mui-core-DHT36AZL.js";import{_ as V,c as ue,a1 as et,ac as tt,b4 as Q,ar as xe,as as he,at as me}from"./index-lFDZOk_k.js";import{u as K}from"./team-KWOyNaWn.js";import{u as ot}from"./use-mobile-DoKVMODs.js";import{u as st,C as X}from"./index.esm-DTmS4tth.js";import{C as ge,a as be,J as nt}from"./vendor-utils-BSZ4yJws.js";import{C as it}from"./confirm-Dge1BR0a.js";import{A as rt}from"./actions-CIp6hu8_.js";import{T as re}from"./table-tips-cVuoMOXE.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-3xKfH3F1.js";import"./session-DR7jqIW5.js";import"./isURL-fcz3vuMN.js";import"./use-app-logo-hGlkw2d_.js";import"./index-DBs9Ljax.js";const lt=n=>{const[p,c]=v.useState(null),[f,r]=v.useState(!0),[w,u]=v.useState(null),j=window.blocklet?.appUrl,a=v.useMemo(()=>{const g={};return p&&(p.sources.forEach(y=>{g[y.did]={source:y,events:[],count:0}}),p.events.forEach(y=>{g[y.source]&&(g[y.source].events.push(y),g[y.source].count+=1)})),g},[p]),b=async()=>{try{if(r(!0),!j)return;const y=await(await fetch(ge(j,ue.WELLKNOWN_SERVICE_PATH_PREFIX,"/openevent.json"))).json();c(y),u(null)}catch(g){u(g instanceof Error?g:new Error(String(g)))}finally{r(!1)}};return v.useEffect(()=>{b()},[j]),{openEvent:p,setOpenEvent:c,eventsBySource:a,loading:f,error:w,loadData:b}};function fe({eventsBySource:n,selectedEvents:p,setSelectedEvents:c,error:f=null}){const{t:r}=L(),[w,u]=v.useState({}),j=v.useMemo(()=>{const s={};return Object.entries(n).forEach(([l,{events:m}])=>{const k=m.filter(T=>p[`${T.type}-${T.source}`]).length;s[l]=k}),s},[n,p]),a=v.useMemo(()=>Object.values(j).reduce((s,l)=>s+l,0),[j]),b=v.useMemo(()=>Object.values(n).reduce((s,{events:l})=>s+l.length,0),[n]),g=(s,l)=>{l.stopPropagation(),u({...w,[s]:!w[s]})},y=s=>{const l=`${s.type}-${s.source}`;c(m=>({...m,[l]:!m[l]}))},z=(s,l)=>{const m={};s.forEach(k=>{const T=`${k.type}-${k.source}`;m[T]=!l}),c(k=>({...k,...m}))},I=s=>{const l={};Object.values(n).forEach(({events:m})=>{m.forEach(k=>{const T=`${k.type}-${k.source}`;l[T]=s.target.checked})}),c(l)};return e.jsxs(d,{sx:{width:"100%"},children:[e.jsxs(d,{sx:{display:"flex",alignItems:"center",mb:1,mt:1},children:[e.jsx(ie,{control:e.jsx(J,{onChange:I,checked:a>0&&a===b}),label:e.jsxs(d,{sx:{display:"flex",alignItems:"center",cursor:"pointer"},children:[r("webhookEndpoint.selectAllEvents"),e.jsx(d,{sx:{display:"flex",alignItems:"center"},children:e.jsx(P,{title:r("webhookEndpoint.selectAllEventsTooltip"),placement:"right",children:e.jsx(_,{fontSize:"small",sx:{ml:.5,cursor:"help"}})})})]}),sx:{m:0}}),a>0&&e.jsx(S,{variant:"body2",color:"primary",sx:{ml:"auto"},children:r("webhookEndpoint.selectedEventsCount",{count:a})})]}),e.jsx(d,{className:"webhook-event-selector",sx:{maxHeight:"50vh",overflowY:"auto",overflowX:"hidden"},children:e.jsx(G,{disablePadding:!0,sx:{border:"1px solid",borderColor:"divider",borderRadius:.5},children:Object.entries(n).map(([s,{source:l,events:m,count:k}],T)=>{const O=j[s]>0,R=j[s]===m.length&&m.length>0,$=w[s];return e.jsxs(ce.Fragment,{children:[e.jsx(Z,{sx:{borderBottom:({palette:i})=>T<Object.keys(n).length-1?`1px solid ${i.divider}`:"none",px:0,py:1,"&:hover":{bgcolor:"rgba(0, 0, 0, 0.02)"}},children:e.jsxs(d,{sx:{display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center"},onClick:i=>{i.target.closest(".MuiFormControlLabel-root")||g(s,i)},children:[e.jsx(d,{sx:{display:"flex",alignItems:"center"},children:m.length>0&&e.jsx(ie,{control:e.jsx(J,{checked:R,indeterminate:O&&!R,onChange:i=>{i.stopPropagation(),z(m,R)}}),label:e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:1},children:[l.logo&&e.jsx(Pe,{src:l.logo,sx:{width:24,height:24}}),e.jsx(d,{children:l.title||s}),O&&e.jsx(B,{label:r("webhookEndpoint.selectedCount",{count:j[s]}),size:"small",sx:{mt:"2px",height:"20px",fontSize:"12px",bgcolor:i=>`${i.palette.primary.main}20`,color:"primary.main",fontWeight:500}})]}),sx:{m:0,"& .MuiFormControlLabel-label":{flex:1}}})}),e.jsxs(d,{sx:{display:"flex",alignItems:"center"},children:[e.jsx(S,{variant:"body2",sx:{color:"text.secondary",mr:1},children:r("webhookEndpoint.eventsCount",{count:k})}),m.length>0&&e.jsx(M,{size:"small",edge:"end",children:$?e.jsx(qe,{}):e.jsx(Be,{})})]})]})}),m.length>0&&e.jsx(Le,{in:$,timeout:"auto",unmountOnExit:!0,children:e.jsx(G,{disablePadding:!0,sx:{p:0,bgcolor:"rgba(0, 0, 0, 0.01)"},children:m.map(i=>{const x=`${i.type}-${i.source}`,t=!!p[x];return e.jsx(Z,{dense:!0,sx:{py:.75,px:1},onClick:()=>y(i),children:e.jsxs(d,{sx:{display:"flex",alignItems:"flex-start",width:"100%"},children:[e.jsx(J,{checked:t,sx:{flexShrink:0}}),e.jsxs(d,{sx:{flex:1,minWidth:0},children:[e.jsx(S,{variant:"body1",className:"webhook-event-type",sx:{cursor:"pointer",color:"text.primary",wordBreak:"break-word",overflowWrap:"break-word"},children:i.type}),e.jsx(S,{variant:"caption",sx:{color:"text.secondary",display:"block",cursor:"pointer",wordBreak:"break-word",overflowWrap:"break-word"},children:i.description})]})]})},x)})})})]},s)})})}),f&&e.jsx(Me,{error:!0,sx:{mt:1},children:f})]})}fe.propTypes={eventsBySource:o.objectOf(o.shape({source:o.shape({did:o.string.isRequired,title:o.string,description:o.string,version:o.string,logo:o.string}).isRequired,events:o.arrayOf(o.shape({type:o.string.isRequired,description:o.string.isRequired,source:o.string.isRequired})).isRequired,count:o.number.isRequired})).isRequired,selectedEvents:o.objectOf(o.bool).isRequired,setSelectedEvents:o.func.isRequired,error:o.string};function je({id:n=null,url:p="",description:c="",enabledEvents:f=[],onSubmit:r,onClose:w=()=>{}}){const{t:u}=L(),[j,a]=v.useState({}),{teamDid:b}=K(),{api:g}=V(),{loading:y,error:z,eventsBySource:I}=lt(),s=ze(),{control:l,handleSubmit:m,formState:{errors:k},reset:T,setValue:O,trigger:R}=st({defaultValues:{url:"",description:""}}),$=de(s.breakpoints.down("md"));v.useEffect(()=>{const t=Object.values(j).some(h=>h);O("selectedEvents",t?"valid":""),R("selectedEvents")},[j,O,R]);const i=()=>{a({}),T(),w()},x=async t=>{const h=Object.keys(j).filter(C=>j[C]),E={url:t.url,description:t.description,enabledEvents:h.map(C=>{const[D,se]=C.split("-");return!D||!se?null:{type:D,source:se}}).filter(Boolean)};try{if(n){const C=await g.updateWebhookEndpoint({input:{teamDid:b,id:n,data:E}});q.success(`${u("webhookEndpoint.updateWebhook")} ${u("webhookEndpoint.success")}`),r(C)}else{const C=await g.createWebhookEndpoint({input:{teamDid:b,input:E}});q.success(`${u("webhookEndpoint.createWebhook")} ${u("webhookEndpoint.success")}`),r(C)}}catch(C){q.error(C?.message)}i()};return v.useEffect(()=>{T({url:p,description:c}),a(f.reduce((t,h)=>(t[`${h.type}-${h.source}`]=!0,t),{}))},[T,a,p,c,f]),e.jsx(De,{open:!0,onClose:i,maxWidth:"lg",fullWidth:!0,fullScreen:$,sx:{"& .MuiDialog-paper":{minHeight:600}},children:e.jsxs("form",{onSubmit:m(x),children:[e.jsx(Oe,{children:u(n?"webhookEndpoint.editWebhookTitle":"webhookEndpoint.createWebhookTitle")}),e.jsx($e,{children:e.jsxs(d,{sx:{display:"flex",flexDirection:"column",gap:2,mt:2},children:[e.jsx(X,{name:"url",control:l,rules:{required:u("webhookEndpoint.validation.urlRequired"),pattern:{value:/^(http|https):\/\/[^ "]+$/,message:u("webhookEndpoint.validation.urlInvalid")}},render:({field:t})=>e.jsx(ne,{...t,label:u("webhookEndpoint.url.label"),fullWidth:!0,error:!!k.url,helperText:k.url?.message})}),e.jsx(X,{name:"description",control:l,rules:{required:u("webhookEndpoint.validation.descriptionRequired")},render:({field:t})=>e.jsx(ne,{...t,label:u("webhookEndpoint.description.label"),fullWidth:!0,multiline:!0,minRows:2,maxRows:4,error:!!k.description,helperText:k.description?.message})}),e.jsx(X,{name:"selectedEvents",control:l,rules:{required:u("webhookEndpoint.validation.eventRequired")},render:({field:t})=>e.jsx("input",{type:"hidden",...t})}),!y&&I&&Object.keys(I).length>0&&e.jsx(fe,{eventsBySource:I,selectedEvents:j,setSelectedEvents:a,error:k.selectedEvents?.message}),!y&&(!I||Object.keys(I).length===0)&&e.jsx(S,{sx:{color:"text.secondary"},children:u("webhookEndpoint.noAvailableEvents")}),y&&e.jsx(d,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"500px",width:"100%"},children:e.jsx(F,{size:20})}),z&&e.jsx(te,{severity:"error",children:u("webhookEndpoint.loadingError",{message:z?.message})})]})}),e.jsxs(Ae,{sx:{p:"8px 24px 24px"},children:[e.jsx(H,{onClick:i,children:u("common.cancel")}),e.jsx(H,{type:"submit",variant:"contained",color:"primary",children:u(n?"webhookEndpoint.updateWebhook":"webhookEndpoint.saveWebhook")})]})]})})}je.propTypes={onSubmit:o.func.isRequired,id:o.string,url:o.string,description:o.string,enabledEvents:o.arrayOf(o.shape({type:o.string.isRequired,source:o.string.isRequired})),onClose:o.func};function ye(n){switch(n){case"enabled":return"success";case"disabled":default:return"default"}}const at=(n="en")=>n==="tw"?"zh":n;function U(n,p="YYYY-MM-DD HH:mm:ss",c="en"){return n?et(n).locale(at(c)).format(p):"-"}function ct(n){return typeof n=="number"?!1:be(n)}function dt(n){return n>=200&&n<300}function A({value:n,label:p,tip:c="",divider:f=!1}){const r=ct(n);return e.jsxs(e.Fragment,{children:[e.jsxs(W,{direction:"column",alignItems:"flex-start",children:[e.jsxs(S,{component:"div",variant:"body1",mb:1,color:"text.primary",sx:{fontWeight:500},children:[p,!!c&&e.jsx(P,{title:c,children:e.jsx(_,{fontSize:"small"})})]}),e.jsx(S,{component:"div",variant:"body1",color:r?"text.disabled":"text.secondary",sx:{width:"100%",minHeight:"24px"},children:r?"-":n})]}),f&&e.jsx(pe,{orientation:"vertical",flexItem:!0})]})}A.propTypes={label:o.oneOfType([o.string,o.node]).isRequired,value:o.oneOfType([o.string,o.node]).isRequired,tip:o.oneOfType([o.string,o.node]),divider:o.bool};function we({title:n,children:p=null,mb:c=1.5,mt:f=1.5}){return e.jsxs(W,{className:"section-header",direction:"row",sx:{justifyContent:"space-between",alignItems:"center",flexWrap:"wrap",gap:1,mb:c,mt:f,pb:1},children:[e.jsx(S,{variant:"h3",sx:{fontSize:{xs:"18px",md:"1.09375rem"}},component:"div",children:n}),p]})}we.propTypes={title:o.oneOfType([o.string,o.node]).isRequired,children:o.node,mb:o.number,mt:o.number};const pt={width:24,height:24,body:'<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20 11A8.1 8.1 0 0 0 4.5 9M4 5v4h4m-4 4a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4"/>'},ut=n=>{const p={};return n.forEach(c=>{const f=new Date(c.createdAt).toLocaleDateString();p[f]||(p[f]=[]),p[f]?.push(c)}),p};function ke({eventId:n="",webhookEndpointId:p="",event:c=null}){const{api:f,ws:{useSubscription:r}}=V(),{t:w}=L(),{teamDid:u}=K(),{blocklet:j}=tt(),{data:a,loadMore:b,loadingMore:g,loading:y,mutate:z}=Re(t=>{const E=t?Math.ceil(t.list.length/15)+1:1;return f.getWebhookAttempts({input:{teamDid:u,input:{eventId:n,webhookId:p},paging:{page:E,pageSize:15}}})},{reloadDeps:[n,p]}),I=a?.list||[],[s,l]=v.useState(null),[m,k]=v.useState(!1),T=ut(I);if(v.useEffect(()=>{!s&&a?.list.length&&l(a.list[0])},[a?.list.length,s]),r(ue.EVENTS.WEBHOOK_ATTEMPT,t=>{z(h=>{if(h.list.find(C=>C.id===t.id)){const C=h.list.map(D=>D.id===t.id?{...D,...t}:D);return{...h,list:C}}return t.endpoint=h.list[0]?.endpoint,t.event=h.list[0]?.event,{...h,list:[t,...h.list]}})},[]),y)return e.jsx(F,{});const O=a&&a.list.length<a.paging.total,R=async()=>{s&&(k(!0),await f.retryWebhookAttempt({input:{teamDid:u,eventId:s.event.id,webhookId:p,attemptId:s.id}}).finally(()=>{setTimeout(()=>{k(!1)},1e3)}))},$=t=>{if(t.responseBody&&t.responseBody?.sessionId&&t.responseBody?.projectId&&t.responseBody?.agentId){const h=j?.site?.domainAliases[0]?.value,E=(j.children||[]).find(D=>D?.meta?.name==="ai-studio"),C=nt(ge(`https://${h}`,E?.mountPoint||"","projects",t.responseBody.projectId,"logs/main"),{sessionId:t.responseBody.sessionId,agentId:t.responseBody.agentId});return e.jsx(M,{sx:{fontSize:20},onClick:()=>window.open(C,"_blank"),children:e.jsx(d,{component:N,icon:Q})})}return null},i=t=>t.status==="pending"?e.jsx(Ue,{color:"warning"}):dt(t.responseStatus)?e.jsx(_e,{color:"success"}):e.jsx(Ve,{color:"error"}),x=s?.triggeredFrom&&(a?.list||[]).find(t=>t.id===s.triggeredFrom);return e.jsxs(xt,{container:!0,spacing:{xs:0,md:1},sx:{height:1},children:[e.jsx(ee,{size:{xs:12,md:4},sx:{height:1},children:be(Object.keys(T))?e.jsx(S,{sx:{color:"text.secondary"},children:w("webhookEndpoint.waitingForEvents")}):e.jsxs(e.Fragment,{children:[e.jsx(G,{sx:{maxHeight:"calc(100% - 40px)",py:0,overflowY:"auto"},children:Object.entries(T).map(([t,h])=>e.jsxs(ce.Fragment,{children:[e.jsx(Fe,{sx:{p:0},children:t}),h.map(E=>e.jsxs(Z,{sx:{cursor:"pointer",px:1},onClick:()=>l(E),selected:s&&s?.id===E?.id,secondaryAction:e.jsx(S,{sx:{color:"text.secondary"},children:U(E.createdAt,"HH:mm:ss")}),children:[e.jsx(He,{sx:{minWidth:0,mr:1.5},children:i(E)}),e.jsx(Ne,{primary:e.jsx(S,{sx:{color:"text.primary"},children:E.event.type})})]},E.id))]},t))}),O&&e.jsx(d,{sx:{display:"flex",justifyContent:"center",alignItems:"center",width:1},children:e.jsx(H,{variant:"text",type:"button",color:"inherit",onClick:b,disabled:g,sx:{color:t=>t.palette.text.disabled},children:w(g?"webhookEndpoint.loadingMore":"webhookEndpoint.loadMore")})})]})}),e.jsxs(ee,{size:{xs:12,md:8},sx:{height:1},children:[s&&e.jsxs(W,{direction:"column",spacing:2,sx:{height:1,overflow:"auto",pl:{xs:0,md:1},mt:{xs:2,md:0},borderLeft:{xs:"none"}},children:[e.jsxs(d,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(S,{variant:"h4",children:w(`common.${s.status}`)}),e.jsx(d,{children:$(s)})]}),e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:1},children:[x&&e.jsx(P,{placement:"left",title:e.jsxs(W,{onClick:()=>l(x),sx:{gap:1,cursor:"pointer",".did-address-text":{color:"common.white"}},children:[e.jsx(xe,{showDid:!0,did:s.triggeredBy,cardType:me.Detailed,infoType:he.Minimal,sx:{border:0,padding:0,minWidth:0,".MuiTypography-root":{color:"common.white",fontWeight:400}}}),e.jsx(pe,{}),e.jsxs(d,{sx:{display:"flex",flexDirection:"column"},children:[e.jsx(S,{variant:"body2",sx:{color:"primary.main"},children:w("webhookEndpoint.triggeredFrom")}),e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(S,{variant:"body2",children:s.id}),e.jsx(M,{onClick:()=>l(x),children:e.jsx(d,{component:N,icon:Q,sx:{fontSize:16,color:"common.white"}})})]})]})]}),slotProps:{tooltip:{sx:{maxWidth:400}}},children:e.jsx(M,{onClick:()=>l(x),children:e.jsx(d,{component:N,icon:Q,sx:{fontSize:16}})})}),e.jsxs(H,{variant:"outlined",color:"primary",size:"small",onClick:R,disabled:m,children:[e.jsx(d,{component:N,icon:pt,sx:{fontSize:16,animation:m?"spin 1s linear infinite":"none",mr:.5}}),w("notification.resend")]})]})]}),e.jsxs(d,{children:[e.jsxs(S,{variant:"h6",children:[w("webhookEndpoint.response")," (",s.responseStatus,")"]}),e.jsx(Y,{language:"json",children:JSON.stringify(s.responseBody,null,2)})]}),e.jsxs(d,{children:[e.jsx(W,{direction:"row",spacing:1,sx:{alignItems:"center"},children:e.jsx(S,{variant:"h6",children:w("webhookEndpoint.request")})}),e.jsx(Y,{language:"json",sx:{margin:0},children:JSON.stringify(s.event,null,2)})]})]}),a?.list.length===0&&c&&e.jsxs(d,{children:[e.jsx(W,{direction:"row",spacing:1,sx:{alignItems:"center"},children:e.jsx(S,{variant:"h6",children:w("webhookEndpoint.eventData")})}),e.jsx(Y,{language:"json",sx:{margin:0},children:JSON.stringify(c.data,null,2)})]})]})]})}ke.propTypes={eventId:o.string,webhookEndpointId:o.string,event:o.shape({type:o.string,data:o.object,request:o.object,requestInfo:o.object})};const xt=oe(ee)`
2
2
  @keyframes spin {
3
3
  to {
4
4
  transform: rotate(360deg);