import{j as u,aY as x,X as t}from"./vendor-mui-core-CDEc-eG6.js";import{U as $}from"./vendor-ux-bFYdDLNG.js";import{y as m}from"./vendor-utils-_C9URqjS.js";import{X as l,a8 as v,bd as y,W as j,be as E,bf as P}from"./index-DGZk149v.js";function R({blocklet:o,ancestors:c=[]}){const e=l(),{inService:s}=e,n=v(o?.status)||y(o?.status),r=`?v=${o?.meta?.version}${n?"~":""}`;let a=s?`${m(E,j,"/blocklet/logo-bundle")}${r}`:m(e.imgPrefix,"blocklet.png");if(o.source==="registry"&&o.deployedFrom&&o.meta.logo)a=`${m(o.deployedFrom,P(o.meta.bundleDid,o.meta.logo))}${r}`;else{const g=window.env?.apiPrefix||"/",i=c.concat(o),p=s?i.slice(1):i;a=`${m(g,`/blocklet/logo-bundle${p.map(d=>`/${d.meta.did}`).join("")}`)}${r}`}return{logoUrl:a,inService:s}}function h({blocklet:o,style:c={},size:e=40,ancestors:s=[],...n}){const r=l(),{logoUrl:a,inService:g}=R({blocklet:o,ancestors:s}),{variant:i}=n,p=g?()=>{}:f=>{f.target.src=`${r.imgPrefix}/blocklet.png`};let d=u.jsx("img",{src:a,onError:p,alt:o.meta.name,style:{width:e}});return o.meta.logo||(d=u.jsx($,{did:o.meta.did||"",responsive:!0})),u.jsx(x,{variant:i||"square",style:Object.assign({backgroundColor:"transparent",width:e,height:e,borderRadius:10},c),...n,children:d})}h.propTypes={blocklet:t.object.isRequired,style:t.object,size:t.oneOfType([t.number,t.string]),ancestors:t.array};export{h as B};
