"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1909],{21909:(e,r,a)=>{a.r(r),a.d(r,{Avatar:()=>E,AvatarFallback:()=>y,AvatarImage:()=>S});var t=a(53891),n=a(73987),l=a(80428),s=a(15949),u=a(637),i=a(4513),o=a(62987);function d(){return()=>{}}var c="Avatar",[f,v]=(0,l.A)(c),[m,g]=f(c),w=n.forwardRef((e,r)=>{let{__scopeAvatar:a,...l}=e,[s,u]=n.useState("idle");return(0,t.jsx)(m,{scope:a,imageLoadingStatus:s,onImageLoadingStatusChange:u,children:(0,t.jsx)(i.sG.span,{...l,ref:r})})});w.displayName=c;var p="AvatarImage",N=n.forwardRef((e,r)=>{let{__scopeAvatar:a,src:l,onLoadingStatusChange:c=()=>{},...f}=e,v=g(p,a),m=function(e,r){let{referrerPolicy:a,crossOrigin:t}=r,l=(0,o.useSyncExternalStore)(d,()=>!0,()=>!1),s=n.useRef(null),i=l?(s.current||(s.current=new window.Image),s.current):null,[c,f]=n.useState(()=>j(i,e));return(0,u.N)(()=>{f(j(i,e))},[i,e]),(0,u.N)(()=>{let e=e=>()=>{f(e)};if(!i)return;let r=e("loaded"),n=e("error");return i.addEventListener("load",r),i.addEventListener("error",n),a&&(i.referrerPolicy=a),"string"==typeof t&&(i.crossOrigin=t),()=>{i.removeEventListener("load",r),i.removeEventListener("error",n)}},[i,t,a]),c}(l,f),w=(0,s.c)(e=>{c(e),v.onImageLoadingStatusChange(e)});return(0,u.N)(()=>{"idle"!==m&&w(m)},[m,w]),"loaded"===m?(0,t.jsx)(i.sG.img,{...f,ref:r,src:l}):null});N.displayName=p;var x="AvatarFallback",h=n.forwardRef((e,r)=>{let{__scopeAvatar:a,delayMs:l,...s}=e,u=g(x,a),[o,d]=n.useState(void 0===l);return n.useEffect(()=>{if(void 0!==l){let e=window.setTimeout(()=>d(!0),l);return()=>window.clearTimeout(e)}},[l]),o&&"loaded"!==u.imageLoadingStatus?(0,t.jsx)(i.sG.span,{...s,ref:r}):null});function j(e,r){return e?r?(e.src!==r&&(e.src=r),e.complete&&e.naturalWidth>0?"loaded":"loading"):"error":"idle"}h.displayName=x;var k=a(61971);function E(e){let{className:r,...a}=e;return(0,t.jsx)(w,{"data-slot":"avatar",className:(0,k.cn)("relative flex size-8 shrink-0 overflow-hidden rounded-full",r),...a})}function S(e){let{className:r,...a}=e;return(0,t.jsx)(N,{"data-slot":"avatar-image",className:(0,k.cn)("aspect-square size-full",r),...a})}function y(e){let{className:r,...a}=e;return(0,t.jsx)(h,{"data-slot":"avatar-fallback",className:(0,k.cn)("bg-muted flex size-full items-center justify-center rounded-full",r),...a})}}}]);