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