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