const e=require("../_util/props-util/index.js"),t=require("../config-provider/hooks/useConfigInject.js"),n=require("../vc-resize-observer/index.js"),r=require("../_util/vue-types/index.js"),i=require("../_util/eagerComputed.js"),a=require("../_util/responsiveObserve.js"),o=require("../_util/hooks/useBreakpoint.js"),s=require("./AvatarContext.js"),c=require("./style/index.js");let l=require("vue");var u=()=>({prefixCls:String,shape:{type:String,default:`circle`},size:{type:[Number,String,Object],default:()=>`default`},src:String,srcset:String,icon:r.default.any,alt:String,gap:Number,draggable:{type:Boolean,default:void 0},crossOrigin:String,loadError:{type:Function}}),d=(0,l.defineComponent)({compatConfig:{MODE:3},name:`AAvatar`,inheritAttrs:!1,props:u(),slots:Object,setup(r,{slots:u,attrs:d}){let f=(0,l.shallowRef)(!0),p=(0,l.shallowRef)(!1),m=(0,l.shallowRef)(1),h=(0,l.shallowRef)(null),g=(0,l.shallowRef)(null),{prefixCls:_}=t.default(`avatar`,r),[v,y]=c.default(_),b=s.useAvatarInjectContext(),x=(0,l.computed)(()=>r.size==="default"?b.size:r.size),S=o.default(),C=i.default(()=>{if(typeof r.size!=`object`)return;let e=a.responsiveArray.find(e=>S.value[e]);return r.size[e]}),w=e=>C.value?{width:`${C.value}px`,height:`${C.value}px`,lineHeight:`${C.value}px`,fontSize:`${e?C.value/2:18}px`}:{},T=()=>{if(!h.value||!g.value)return;let e=h.value.offsetWidth,t=g.value.offsetWidth;if(e!==0&&t!==0){let{gap:n=4}=r;n*2<t&&(m.value=t-n*2<e?(t-n*2)/e:1)}},E=()=>{let{loadError:e}=r;e?.()!==!1&&(f.value=!1)};return(0,l.watch)(()=>r.src,()=>{(0,l.nextTick)(()=>{f.value=!0,m.value=1})}),(0,l.watch)(()=>r.gap,()=>{(0,l.nextTick)(()=>{T()})}),(0,l.onMounted)(()=>{(0,l.nextTick)(()=>{T(),p.value=!0})}),()=>{let{shape:t,src:i,alt:a,srcset:o,draggable:s,crossOrigin:c}=r,S=b.shape??t,C=e.getPropsSlot(u,r,`icon`),D=_.value,O={[`${d.class}`]:!!d.class,[D]:!0,[`${D}-lg`]:x.value===`large`,[`${D}-sm`]:x.value===`small`,[`${D}-${S}`]:!0,[`${D}-image`]:i&&f.value,[`${D}-icon`]:C,[y.value]:!0},k=typeof x.value==`number`?{width:`${x.value}px`,height:`${x.value}px`,lineHeight:`${x.value}px`,fontSize:C?`${x.value/2}px`:`18px`}:{},A=u.default?.(),j;if(i&&f.value)j=(0,l.createVNode)(`img`,{draggable:s,src:i,srcset:o,onError:E,alt:a,crossorigin:c},null);else if(C)j=C;else if(p.value||m.value!==1){let e=`scale(${m.value}) translateX(-50%)`,t={msTransform:e,WebkitTransform:e,transform:e},r=typeof x.value==`number`?{lineHeight:`${x.value}px`}:{};j=(0,l.createVNode)(n.default,{onResize:T},{default:()=>[(0,l.createVNode)(`span`,{class:`${D}-string`,ref:h,style:{...r,...t}},[A])]})}else j=(0,l.createVNode)(`span`,{class:`${D}-string`,ref:h,style:{opacity:0}},[A]);return v((0,l.createVNode)(`span`,{...d,ref:g,class:O,style:[k,w(!!C),d.style]},[j]))}}});exports.avatarProps=u,exports.default=d;