import{c as B,a as f,n as d,t as L,f as P,I as $,w as j}from"./SvgIcon-Cza0IrRi.js";import{d as D,f as g,aa as N,g as T,E as _,w as C,$ as M,a0 as R,N as U,J as z,b as n,a1 as A,ab as F,m as S}from"./index-DA4V3bi7.js";window.getBuildInfo=function(){return{buildTime:"12/28/2024, 9:18:06 AM",branch:"null"}};const[J,i]=B("image"),O={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"),crossorigin:String,referrerpolicy:String};var V=D({name:J,props:O,emits:["load","error"],setup(r,{emit:u,slots:c}){const t=g(!1),o=g(!0),a=g(),{$Lazyload:l}=N().proxy,E=T(()=>{const e={width:f(r.width),height:f(r.height)};return _(r.radius)&&(e.overflow="hidden",e.borderRadius=f(r.radius)),e});C(()=>r.src,()=>{t.value=!1,o.value=!0});const v=e=>{o.value&&(o.value=!1,u("load",e))},m=()=>{const e=new Event("load");Object.defineProperty(e,"target",{value:a.value,enumerable:!0}),v(e)},h=e=>{t.value=!0,o.value=!1,u("error",e)},w=(e,s,I)=>I?I():n($,{name:e,size:r.iconSize,class:s,classPrefix:r.iconPrefix},null),k=()=>{if(o.value&&r.showLoading)return n("div",{class:i("loading")},[w(r.loadingIcon,i("loading-icon"),c.loading)]);if(t.value&&r.showError)return n("div",{class:i("error")},[w(r.errorIcon,i("error-icon"),c.error)])},x=()=>{if(t.value||!r.src)return;const e={alt:r.alt,class:i("img"),style:{objectFit:r.fit,objectPosition:r.position},crossorigin:r.crossorigin,referrerpolicy:r.referrerpolicy};return r.lazyLoad?A(n("img",S({ref:a},e),null),[[F("lazy"),r.src]]):n("img",S({ref:a,src:r.src,onLoad:v,onError:h},e),null)},y=({el:e})=>{const s=()=>{e===a.value&&o.value&&m()};a.value?s():z(s)},b=({el:e})=>{e===a.value&&!t.value&&h()};return l&&M&&(l.$on("loaded",y),l.$on("error",b),R(()=>{l.$off("loaded",y),l.$off("error",b)})),U(()=>{z(()=>{var e;(e=a.value)!=null&&e.complete&&!r.lazyLoad&&m()})}),()=>{var e;return n("div",{class:i({round:r.round,block:r.block}),style:E.value},[x(),k(),(e=c.default)==null?void 0:e.call(c)])}}});const H=j(V);export{H as I};
