import{_ as G}from"./Bgk-2nau.js";import{aw as k,ax as R,ay as X}from"./BmsEUx_s.js";import{g as Y,b as Z}from"./CUL2_9oX.js";import{k as q,a as T,b as J,l as o,u as t,G as v,H as W,I as K,M as Q,a1 as z,a2 as E,O as ee,a3 as te,X as I,$ as ae,L as se}from"./BO9AmBA3.js";var U=(i=>(i.FULL="100%",i.AUTO="auto",i))(U||{});const re=["src","type"],oe=10,ue=q({__name:"CmsElementImage",props:{content:{},autoHeight:{type:Boolean},autoWidth:{type:Boolean},whiteBackground:{type:Boolean},classes:{},preload:{type:Boolean},eager:{type:Boolean},sizes:{},maxThumbnail:{}},setup(i){const r=i,{containerStyle:ne,displayMode:c,imageContainerAttrs:j,imageAttrs:m,imageLink:L,isVideoElement:$,mimeType:P}=k(r.content),u=T(),H=e=>[...e.split(",")].sort((l,n)=>{const p=S=>{var f;return parseInt(((f=S.match(/\d+w$/))==null?void 0:f[0].replace("w",""))||"",10)};return p(l)-p(n)}).join(","),M=(e,a)=>[...e.split(",")].filter((n,p)=>(f=>{var _;return parseInt(((_=f.match(/\d+w$/))==null?void 0:_[0].replace("w",""))||"",10)})(n)<=a);J(()=>r.content,()=>{var a,s;const{imageAttrs:e}=k(r.content);u.value=((a=e.value)==null?void 0:a.srcset)&&H((s=e.value)==null?void 0:s.srcset),r.maxThumbnail&&(u.value=M(u.value,r.maxThumbnail))},{immediate:!0});const N=o(()=>{var e,a,s;return(s=(a=(e=r.content.data)==null?void 0:e.media)==null?void 0:a.metaData)==null?void 0:s.width}),V=o(()=>{var e,a,s;return(s=(a=(e=r.content.data)==null?void 0:e.media)==null?void 0:a.metaData)==null?void 0:s.height}),{getConfigValue:d}=R(r.content),y=o(()=>d("maxWidth")),D=o(()=>d("height")),h=o(()=>d("verticalAlign")),g=o(()=>d("horizontalAlign")),w=o(()=>r.autoHeight||D.value===U.AUTO),A=T(null),{width:b,height:x}=X(A);function C(e){return e?Math.ceil(e/100)*100:oe}const B=o(()=>{const e=b.value>x.value?`width=${C(b.value)}`:`height=${C(x.value)}`;return encodeURI(`${m.value.src}?${e}&fit=crop,smart`)}),O=Y(),F=o(()=>{const e=Object.assign({},j.value);return e!=null&&e.href&&(e.href=Z(e.href,O)),e});return(e,a)=>{const s=G;return t(m).src?(v(),W(se(t(L).url?"a":"div"),ae({key:0,class:{"cms-element-image relative h-full w-full":!0,"bg-white":e.whiteBackground,flex:t(g)||t(h),"items-center":t(h)==="center","items-start":t(h)==="flex-start","items-end":t(h)==="flex-end","justify-center":t(g)==="center","justify-start":t(g)==="flex-start","justify-end":t(g)==="flex-end"}},t(F)),{default:K(()=>{var l,n;return[t($)?(v(),Q("video",{key:0,controls:"",class:z([(l=e.classes)==null?void 0:l.image,{"h-full w-full":!0,"absolute inset-0":["cover","stretch"].includes(t(c)),"object-cover":t(c)==="cover"}]),style:E({maxWidth:t(y)})},[ee("source",{src:t(m).src,type:t(P)},null,8,re),te(" Your browser does not support the video tag. ")],6)):t(B)?(v(),W(s,{key:1,ref_key:"imageElement",ref:A,loading:e.eager?"eager":"lazy",class:z([(n=e.classes)==null?void 0:n.image,{"h-full":!t(w),"h-auto":t(w),"w-full":!e.autoWidth,"w-auto":e.autoWidth,"absolute inset-0":["cover","stretch"].includes(t(c)),"object-cover":t(c)==="cover"}]),preload:e.preload,alt:t(m).alt,src:t(B),srcset:t(u),format:"webp",sizes:e.sizes,densities:"x1",style:E({maxWidth:t(y)}),width:t(N),height:t(V)},null,8,["loading","class","preload","alt","src","srcset","sizes","style","width","height"])):I("",!0)]}),_:1},16,["class"])):I("",!0)}}});export{ue as _};