import{o as e}from"./chunk.DuxOD-Sk.js";import{r as t}from"./emotion-is-prop-valid.esm.DV_OErv-.js";import{c as n,l as r,t as i}from"./emotion-styled.browser.esm.BPUx6WuE.js";import{t as a}from"./loglevel.H4SN4KQm.js";import{K as o,St as s}from"./src.sR_9Xh2m.js";import{x as c}from"./ErrorElement.BPchO-rz.js";import{t as l}from"./useCrossOriginAttribute.wOZu23rZ.js";import{t as u}from"./useRequiredContext.DPvSYqB2.js";import{n as d,t as f}from"./withFullScreenWrapper.Ddw274PI.js";var p=e(t()),m=e(a()),h=i(`div`,{target:`ehg91i90`})(({theme:e,shouldStretch:t})=>({display:`flex`,flexDirection:`row`,flexWrap:`wrap`,rowGap:e.spacing.lg,maxWidth:`100%`,width:t?`100%`:`fit-content`})),g=i(`div`,{target:`ehg91i91`})(({theme:e,shouldStretch:t})=>({display:`flex`,flexDirection:`column`,alignItems:`stretch`,width:t?`100%`:`auto`,flexGrow:+!!t,">img":{borderRadius:e.radii.default}})),_=i(`div`,{target:`ehg91i92`})(({theme:e})=>({textAlign:`center`,marginTop:e.spacing.xs,wordWrap:`break-word`,padding:e.spacing.threeXS})),v=i(`a`,{target:`ehg91i93`})(({theme:e})=>({display:`block`,borderRadius:e.radii.default,overflow:`hidden`,"&:hover":{opacity:.85},"&:focus-visible":{boxShadow:e.shadows.focusRing}})),y=(0,m.getLogger)(`ImageList`);function b(e,t){if(e){if(e.useStretch)return t;if(e.useContent)return;if(e.pixelWidth)return e.pixelWidth}}var x=({itemKey:e,image:t,imgStyle:i,buildMediaURL:a,handleImageError:o,shouldStretch:c,link:u})=>{let d=l(t.url),f=n(`img`,{style:i,src:a(t.url),alt:e,onError:o,crossOrigin:d});return r(g,{"data-testid":`stImageContainer`,shouldStretch:c,children:[u?n(v,{href:u,target:`_blank`,rel:`noreferrer`,"aria-label":t.caption||u,"data-testid":`stImageLink`,children:f}):f,t.caption&&n(_,{"data-testid":`stImageCaption`,style:i,children:n(s,{source:t.caption,allowHTML:!1,isCaption:!0,isLabel:!0})})]})};function S({element:e,endpoints:t,widthConfig:i,disableFullscreenMode:a}){let{expanded:s,width:l,height:f,expand:p,collapse:m}=u(d),g=l||0,_=b(i,g),v=i?.useStretch??!1,S={};f&&s?(S.maxHeight=f,S.objectFit=`contain`,S.width=`100%`):(S.width=_??`100%`,S.maxWidth=`100%`);let C=e=>{let n=e.currentTarget.src;y.error(`Client Error: Image source error - ${n}`),t.sendClientErrorToHost(`Image`,`Image source failed to load`,`onerror triggered`,n)};return r(c,{width:g,height:f,useContainerWidth:s,topCentered:!0,children:[n(o,{target:c,isFullScreen:s,onExpand:p,onCollapse:m,disableFullscreenMode:a}),n(h,{className:`stImage`,"data-testid":`stImage`,shouldStretch:v,children:e.imgs.map((r,i)=>n(x,{itemKey:i.toString(),image:r,imgStyle:S,buildMediaURL:e=>t.buildMediaURL(e),handleImageError:C,shouldStretch:v,link:e.imgs.length===1?e.link:void 0},i))})]})}var C=f(S),w=(0,p.memo)(C);export{w as default};