import{t as k,E as d,u as L,y as P,d as E,R as u,a9 as B,D as $,U as f,a1 as D,Z as R,aa as U,ab as _,c as r,ac as j,ad as C,v as z,_ as N,a5 as F,x as T}from"./index.8f93de0e.js";const[V,o]=k("image"),Z={src:String,alt:String,fit:String,position:String,round:Boolean,block:Boolean,width:d,height:d,radius:d,lazyLoad:Boolean,iconSize:d,showError:L,errorIcon:P("photo-fail"),iconPrefix:String,showLoading:L,loadingIcon:P("photo")};var q=E({name:V,props:Z,emits:["load","error"],setup(e,{emit:g,slots:l}){const n=u(!1),t=u(!0),s=u(),{$Lazyload:i}=B().proxy,b=$(()=>{const a={width:f(e.width),height:f(e.height)};return D(e.radius)&&(a.overflow="hidden",a.borderRadius=f(e.radius)),a});R(()=>e.src,()=>{n.value=!1,t.value=!0});const v=a=>{t.value=!1,g("load",a)},h=a=>{n.value=!0,t.value=!1,g("error",a)},m=(a,c,I)=>I?I():r(F,{name:a,size:e.iconSize,class:c,classPrefix:e.iconPrefix},null),S=()=>{if(t.value&&e.showLoading)return r("div",{class:o("loading")},[m(e.loadingIcon,o("loading-icon"),l.loading)]);if(n.value&&e.showError)return r("div",{class:o("error")},[m(e.errorIcon,o("error-icon"),l.error)])},x=()=>{if(n.value||!e.src)return;const a={alt:e.alt,class:o("img"),style:{objectFit:e.fit,objectPosition:e.position}};return e.lazyLoad?j(r("img",z({ref:s},a),null),[[C("lazy"),e.src]]):r("img",z({src:e.src,onLoad:v,onError:h},a),null)},w=({el:a})=>{const c=()=>{a===s.value&&t.value&&v()};s.value?c():N(c)},y=({el:a})=>{a===s.value&&!n.value&&h()};return i&&U&&(i.$on("loaded",w),i.$on("error",y),_(()=>{i.$off("loaded",w),i.$off("error",y)})),()=>{var a;return r("div",{class:o({round:e.round,block:e.block}),style:b.value},[x(),S(),(a=l.default)==null?void 0:a.call(l)])}}});const G=T(q);export{G as I};
