import{r as t,j as i,a as x}from"./index-D5aSL5Lk.js";const z=(s={})=>{const{threshold:f=0,root:a=null,rootMargin:r="50px",freezeOnceVisible:c=!1,initialIsIntersecting:n=!1}=s,g=t.useRef(null),[l,e]=t.useState(n);return t.useEffect(()=>{const o=g.current;if(!o||c&&l)return;if(!("IntersectionObserver"in window)){e(!0);return}const d=new IntersectionObserver(([m])=>{const u=m.isIntersecting;e(u),u&&c&&d.unobserve(o)},{threshold:f,root:a,rootMargin:r});return d.observe(o),()=>{d.disconnect()}},[g,f,a,r,c,l]),[g,l]},R=({src:s,alt:f,width:a,height:r,className:c,objectFit:n="contain",loading:g="lazy",sizes:l="100vw",priority:e=!1})=>{const[o,d]=t.useState(!1),[m,u]=t.useState(!1),[E,v]=t.useState(e?s:null),[S,I]=z({threshold:0,rootMargin:"100px",freezeOnceVisible:!0,initialIsIntersecting:e}),b="/placeholder.svg",p=s.startsWith("http")||s.startsWith("//");t.useEffect(()=>{(e||I)&&v(s)},[I,e,s]);const j=()=>{u(!0)},w=()=>{d(!0),u(!0),v(b)},h=o?b:E,O=!m&&!e;return i.jsxs("div",{ref:S,className:x("relative overflow-hidden bg-muted",c),style:{aspectRatio:a&&r?`${a}/${r}`:void 0},children:[O&&i.jsx("div",{className:"absolute inset-0 animate-pulse",style:{background:"linear-gradient(110deg, hsl(var(--muted)) 8%, hsl(var(--muted) / 0.6) 18%, hsl(var(--muted)) 33%)",backgroundSize:"200% 100%",animation:"shimmer 1.5s linear infinite"},"aria-hidden":"true"}),h&&i.jsxs("picture",{children:[!o&&p&&i.jsx(i.Fragment,{}),i.jsx("img",{src:h,alt:f,width:a,height:r,loading:e?"eager":"lazy",decoding:e?"sync":"async",sizes:l,onLoad:j,onError:w,className:x("w-full h-full transition-opacity duration-500",m?"opacity-100":"opacity-0",n==="contain"&&"object-contain",n==="cover"&&"object-cover",n==="fill"&&"object-fill",n==="none"&&"object-none",n==="scale-down"&&"object-scale-down"),style:{contentVisibility:e?"visible":"auto"},draggable:!1})]})]})};export{R as O};