import{i as y,u as b,a as w,m as E,p as d}from"./_ECBCnJP.js";import{e as k}from"./Cfh3kXIQ.js";import{l as I,ad as S,b as p,k as l,z as B,E as P,P as C,G as L,u as v}from"./DEIzhR9A.js";const N=["src"],M=I({__name:"NuxtImg",props:y,emits:["load","error"],setup(f,{emit:g}){const s=f,h=S(),o=g,z=!1,u=b(),r=w(s),n=p(!1),a=p(),i=l(()=>u.getSizes(s.src,{...r.options.value,sizes:s.sizes,densities:s.densities,modifiers:{...r.modifiers.value,width:d(s.width),height:d(s.height)}})),_=l(()=>{const e={...r.attrs.value,"data-nuxt-img":""};return(!s.placeholder||n.value)&&(e.sizes=i.value.sizes,e.srcset=i.value.srcset),e}),c=l(()=>{let e=s.placeholder;if(e===""&&(e=!0),!e||n.value)return!1;if(typeof e=="string")return e;const t=Array.isArray(e)?e:typeof e=="number"?[e,e]:[10,10];return u(s.src,{...r.modifiers.value,width:t[0],height:t[1],quality:t[2]||50,blur:t[3]||3},r.options.value)}),m=l(()=>s.sizes?i.value.src:u(s.src,r.modifiers.value,r.options.value)),A=l(()=>c.value?c.value:m.value),x=k().isHydrating;return B(()=>{if(c.value){const e=new Image;m.value&&(e.src=m.value),s.sizes&&(e.sizes=i.value.sizes||"",e.srcset=i.value.srcset),e.onload=t=>{n.value=!0,o("load",t)},E("nuxt-image");return}a.value&&(a.value.complete&&x&&(a.value.getAttribute("data-error")?o("error",new Event("error")):o("load",new Event("load"))),a.value.onload=e=>{o("load",e)},a.value.onerror=e=>{o("error",e)})}),(e,t)=>(P(),C("img",L({ref_key:"imgEl",ref:a,class:s.placeholder&&!n.value?s.placeholderClass:void 0},{...v(z)?{onerror:"this.setAttribute('data-error', 1)"}:{},..._.value,...v(h)},{src:A.value}),null,16,N))}});export{M as _};