import{c as h,r as I,bC as j,bd as C,j as t,a as y,bc as E,l as L}from"./index-DCNLpqIv.js";import{w as M,E as S}from"./withFullScreenWrapper-C3PKUCi4.js";import{S as u,T as v}from"./Toolbar-DiWCQxr5.js";const W=h("div",{target:"e115fcil2"})(({theme:e})=>({display:"flex",flexDirection:"row",flexWrap:"wrap",rowGap:e.spacing.lg,maxWidth:"100%",width:"fit-content"}),""),F=h("div",{target:"e115fcil1"})(({theme:e})=>({display:"flex",flexDirection:"column",alignItems:"stretch",width:"auto",flexGrow:0,">img":{borderRadius:e.radii.default}}),""),R=h("div",{target:"e115fcil0"})(({theme:e})=>({textAlign:"center",marginTop:e.spacing.xs,wordWrap:"break-word",padding:e.spacing.threeXS}),""),T=L.getLogger("ImageList"),H=({itemKey:e,image:i,imgStyle:d,buildMediaURL:n,handleImageError:r})=>{const c=y(i.url);return t.jsxs(F,{"data-testid":"stImageContainer",children:[t.jsx("img",{style:d,src:n(i.url),alt:e,onError:r,crossOrigin:c}),i.caption&&t.jsx(R,{"data-testid":"stImageCaption",style:d,children:t.jsx(E,{source:i.caption,allowHTML:!1,isCaption:!0,isLabel:!0})})]})};function G({element:e,endpoints:i,disableFullscreenMode:d}){const n=j(e.imgs),{expanded:r,width:c,height:g,expand:x,collapse:f}=C(S),p=c||0;let l;const s=e.width;if([-1,-3,-4].includes(s))l=void 0;else if([-2,-5].includes(s))l=p;else if(s>0)l=s;else throw Error(`Invalid image width: ${s}`);const a={};g&&r?(a.maxHeight=g,a.objectFit="contain",a.width="100%"):(a.width=l??"100%",a.maxWidth="100%");const w=m=>{const o=m.currentTarget.src;T.error(`Client Error: Image source error - ${o}`),i.sendClientErrorToHost("Image","Image source failed to load","onerror triggered",o)};return t.jsxs(u,{width:p,height:g,useContainerWidth:r,topCentered:!0,children:[t.jsx(v,{target:u,isFullScreen:r,onExpand:x,onCollapse:f,disableFullscreenMode:d}),t.jsx(W,{className:"stImage","data-testid":"stImage",children:n.map((m,o)=>t.jsx(H,{itemKey:o.toString(),image:m,imgStyle:a,buildMediaURL:b=>i.buildMediaURL(b),handleImageError:w},o))})]})}const U=M(G),A=I.memo(U);export{A as default};
