import{a as e,n as t}from"./preload-helper-DxX6f4wy.js";import{$ as n,E as r,F as i,I as a,P as o,d as s,f as c,g as l}from"./Fade-Bj1YUcWe.js";import{r as u}from"./ButtonBase-dVPwHUcG.js";import{t as d}from"./useSlot-dcyUConq.js";var f=e(t()),p=n(),m=u((0,p.jsx)(`path`,{d:`M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z`}),`Person`);function h(e){return i(`MuiAvatar`,e)}o(`MuiAvatar`,[`root`,`colorDefault`,`circular`,`rounded`,`square`,`img`,`fallback`]);var g=e=>{let{classes:t,variant:n,colorDefault:i}=e;return r({root:[`root`,n,i&&`colorDefault`],img:[`img`],fallback:[`fallback`]},h,t)},_=l(`div`,{name:`MuiAvatar`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,t[n.variant],n.colorDefault&&t.colorDefault]}})(c(({theme:e})=>({position:`relative`,display:`flex`,alignItems:`center`,justifyContent:`center`,flexShrink:0,width:40,height:40,fontFamily:e.typography.fontFamily,fontSize:e.typography.pxToRem(20),lineHeight:1,borderRadius:`50%`,overflow:`hidden`,userSelect:`none`,variants:[{props:{variant:`rounded`},style:{borderRadius:(e.vars||e).shape.borderRadius}},{props:{variant:`square`},style:{borderRadius:0}},{props:{colorDefault:!0},style:{color:(e.vars||e).palette.background.default,...e.vars?{backgroundColor:e.vars.palette.Avatar.defaultBg}:{backgroundColor:e.palette.grey[400],...e.applyStyles(`dark`,{backgroundColor:e.palette.grey[600]})}}}]}))),v=l(`img`,{name:`MuiAvatar`,slot:`Img`,overridesResolver:(e,t)=>t.img})({width:`100%`,height:`100%`,textAlign:`center`,objectFit:`cover`,color:`transparent`,textIndent:1e4}),y=l(m,{name:`MuiAvatar`,slot:`Fallback`,overridesResolver:(e,t)=>t.fallback})({width:`75%`,height:`75%`});function b({crossOrigin:e,referrerPolicy:t,src:n,srcSet:r}){let[i,a]=f.useState(!1);return f.useEffect(()=>{if(!n&&!r)return;a(!1);let i=!0,o=new Image;return o.onload=()=>{i&&a(`loaded`)},o.onerror=()=>{i&&a(`error`)},o.crossOrigin=e,o.referrerPolicy=t,o.src=n,r&&(o.srcset=r),()=>{i=!1}},[e,t,n,r]),i}var x=f.forwardRef(function(e,t){let n=s({props:e,name:`MuiAvatar`}),{alt:r,children:i,className:o,component:c=`div`,slots:l={},slotProps:u={},imgProps:f,sizes:m,src:h,srcSet:x,variant:S=`circular`,...C}=n,w=null,T={...n,component:c,variant:S},E=b({...f,...typeof u.img==`function`?u.img(T):u.img,src:h,srcSet:x}),D=h||x,O=D&&E!==`error`;T.colorDefault=!O,delete T.ownerState;let k=g(T),[A,j]=d(`img`,{className:k.img,elementType:v,externalForwardedProps:{slots:l,slotProps:{img:{...f,...u.img}}},additionalProps:{alt:r,src:h,srcSet:x,sizes:m},ownerState:T});return w=O?(0,p.jsx)(A,{...j}):i||i===0?i:D&&r?r[0]:(0,p.jsx)(y,{ownerState:T,className:k.fallback}),(0,p.jsx)(_,{as:c,className:a(k.root,o),ref:t,...C,ownerState:T,children:w})});export{x as t};