import C from"./Icon.fe8c0e68.js";import{E as w,G as f,g as E,j as r,N as i,r as $,D as j,o as s,c as n,K as B,y as o,t as d,k as P,l as h,H as A}from"./entry.9e31e8a4.js";import{t as y}from"./tw-merge.27ca352e.js";import{d as I,u as N}from"./ui.config.7ae255de.js";import{_ as O}from"./_plugin-vue_export-helper.c27b6911.js";const t=w(f.ui.strategy,f.ui.avatar,I),U=E({components:{UIcon:C},inheritAttrs:!1,props:{src:{type:[String,Boolean],default:null},alt:{type:String,default:null},text:{type:String,default:null},icon:{type:String,default:()=>t.default.icon},size:{type:String,default:()=>t.default.size,validator(e){return Object.keys(t.size).includes(e)}},chipColor:{type:String,default:()=>t.default.chipColor,validator(e){return["gray",...f.ui.colors].includes(e)}},chipPosition:{type:String,default:()=>t.default.chipPosition,validator(e){return Object.keys(t.chip.position).includes(e)}},chipText:{type:[String,Number],default:null},imgClass:{type:String,default:""},ui:{type:Object,default:void 0}},setup(e){const{ui:a,attrs:m,attrsClass:g}=N("avatar",e.ui,t),u=r(()=>typeof e.src=="boolean"?null:e.src),v=r(()=>(e.alt||"").split(" ").map(b=>b.charAt(0)).join("").substring(0,2)),c=r(()=>y(i(a.value.wrapper,(l.value||!u.value)&&a.value.background,a.value.rounded,a.value.size[e.size]),g)),p=r(()=>y(i(a.value.rounded,a.value.size[e.size]),e.imgClass)),k=r(()=>i(a.value.icon.base,a.value.icon.size[e.size])),z=r(()=>i(a.value.chip.base,a.value.chip.size[e.size],a.value.chip.position[e.chipPosition],a.value.chip.background.replaceAll("{color}",e.chipColor))),l=$(!1);j(()=>e.src,()=>{l.value&&(l.value=!1)});function S(){l.value=!0}return{ui:a,attrs:m,wrapperClass:c,imgClass:p,iconClass:k,chipClass:z,url:u,placeholder:v,error:l,onError:S}}}),D=["alt","src"];function T(e,a,m,g,u,v){const c=C;return s(),n("span",{class:o(e.wrapperClass)},[e.url&&!e.error?(s(),n("img",B({key:0,class:e.imgClass,alt:e.alt,src:e.url},e.attrs,{onError:a[0]||(a[0]=(...p)=>e.onError&&e.onError(...p))}),null,16,D)):e.text?(s(),n("span",{key:1,class:o(e.ui.text)},d(e.text),3)):e.icon?(s(),P(c,{key:2,name:e.icon,class:o(e.iconClass)},null,8,["name","class"])):e.placeholder?(s(),n("span",{key:3,class:o(e.ui.placeholder)},d(e.placeholder),3)):h("",!0),e.chipColor?(s(),n("span",{key:4,class:o(e.chipClass)},d(e.chipText),3)):h("",!0),A(e.$slots,"default")],2)}const V=O(U,[["render",T]]);export{V as default};
