import{a as e,n as t}from"./preload-helper-DxX6f4wy.js";import{$ as n,O as r,tt as i}from"./Fade-Bj1YUcWe.js";import{t as a}from"./Box-BoFhqo9n.js";import{r as o}from"./siteStore-BLhBstND.js";import{i as s}from"./media-C5azgant.js";var c=e(t(),1),l=n(),u=i`
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
`;function d({src:e,alt:t=``,aspectRatio:n,objectFit:i=`cover`,placeholder:d=`color`,rootMargin:f=`100px`,onLoad:p,onError:m,style:h,...g}){let{config:_}=o(),v=_.lazyLoadMedia??!1,y=s(e),b=v&&y,[x,S]=(0,c.useState)(!1),[C,w]=(0,c.useState)(!1),[T,E]=(0,c.useState)(!b),D=(0,c.useRef)(null);(0,c.useEffect)(()=>{if(!b){E(!0);return}S(!1),w(!1);let e=D.current;if(!e)return;let t=new IntersectionObserver(([e])=>{e.isIntersecting&&(E(!0),t.disconnect())},{rootMargin:f});return t.observe(e),()=>t.disconnect()},[e,b,f]);let O=()=>{S(!0),w(!1),p?.()},k=()=>{w(!0),S(!0),m?.()},A=d!==`none`&&!x&&!C;return(0,l.jsxs)(a,{ref:D,sx:{position:`relative`,width:`100%`,height:`100%`,aspectRatio:n,overflow:`hidden`,backgroundColor:e=>A?r(e.palette.primary.main,.06):`transparent`},children:[A&&(0,l.jsx)(a,{sx:{position:`absolute`,inset:0,width:`100%`,height:`100%`,overflow:`hidden`,"&::after":{content:`""`,position:`absolute`,inset:0,background:e=>`linear-gradient(90deg, transparent, ${r(e.palette.background.paper,e.palette.mode===`light`?.4:.15)}, transparent)`,animation:`${u} 1.6s infinite`}}}),C&&(0,l.jsx)(a,{sx:{position:`absolute`,inset:0,bgcolor:e=>r(e.palette.primary.main,.06)}}),T&&e&&!C&&(0,l.jsx)(a,{component:`img`,src:e,alt:t,onLoad:O,onError:k,sx:{width:`100%`,height:`100%`,objectFit:i,display:`block`,opacity:+!!x,transition:e=>e.transitions.create(`opacity`,{duration:600}),...h},...g})]})}export{d as t};