"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("react/jsx-runtime"),m=require("../index-DnaHaH_0.js"),N=require("react"),h=require("../Slot-ghrohQLA.js"),q=require("@spark-ui/icons/PenOutline"),w=require("../Icon-Bf0XrmiR.js"),R=require("../IconButton-Bf-EDzpI.js");function $(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const a=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,a.get?a:{enumerable:!0,get:()=>e[t]})}}return n.default=e,Object.freeze(n)}const b=$(N),P=b.createContext(void 0),v=()=>{const e=b.useContext(P);if(!e)throw new Error("useAvatarContext must be used within an Avatar component");return e},j={xs:24,sm:32,md:40,lg:56,xl:64,"2xl":96},z=b.forwardRef(({className:e,size:n="xl",isOnline:t=!1,onlineText:a,username:s,asChild:l,children:i,shape:c="circle",...o},u)=>{const d=l?h.Slot:"div",r=b.useMemo(()=>({size:n,isOnline:t,onlineText:a,username:s,shape:c,pixelSize:j[n]}),[n,t,s,c,a]);return x.jsx(P.Provider,{value:r,children:x.jsx(d,{ref:u,style:{width:j[n],height:j[n]},"data-spark-component":"avatar",className:m.cx("relative inline-flex items-center justify-center",e),...o,children:i})})});z.displayName="Avatar";const O=({className:e,asChild:n,src:t,onLoad:a,onError:s,...l})=>{const{username:i,isOnline:c,onlineText:o}=v(),u=n?h.Slot:"img",[d,r]=N.useState(!1),y=c&&o?`${i} (${o})`:i;if(N.useEffect(()=>{r(!1)},[t]),!t)return null;const g=A=>{r(!0),a?.(A)},p=A=>{r(!1),s?.(A)};return x.jsx(u,{"aria-hidden":!0,className:m.cx("absolute inset-0 size-full","object-cover",{"transition-all duration-300 group-hover:scale-120":l.onClick},"focus-visible:u-outline",d?"block":"hidden",e),alt:y,src:t,onLoad:g,onError:p,...l})};O.displayName="AvatarImage";const S=({className:e,children:n,asChild:t,angle:a=135,ariaLabel:s,...l})=>{const i=t?h.Slot:R.IconButton,{pixelSize:c,shape:o}=v();function u(y){const g=(90-a)*Math.PI/180,p=y/2;return{x:p+p*Math.cos(g),y:p-p*Math.sin(g)}}const d=u(c),r=t;return x.jsx(i,{"data-spark-component":"avatar-action",style:{position:"absolute",...o==="circle"?{left:`${d.x}px`,top:`${d.y}px`}:{},...o==="square"?{right:"0px",bottom:"0px"}:{}},className:m.cx("z-raised",o==="circle"?"-translate-x-1/2 -translate-y-1/2":"translate-x-1/4 translate-y-1/4",{"shadow-sm":!r},e),"aria-label":s,title:s,...r?{}:{size:"sm",intent:"support",design:"contrast"},...l,children:n||x.jsx(w.Icon,{size:"sm",children:x.jsx(q.PenOutline,{})})})};S.displayName="AvatarAction";const C=({angle:e=135,...n})=>{const{isOnline:t,pixelSize:a,shape:s,onlineText:l,size:i}=v();if(!t)return null;function c(u){const d=(90-e)*Math.PI/180,r=u/2;return{x:r+r*Math.cos(d),y:r-r*Math.sin(d)}}const o=c(a);return x.jsx("div",{"data-spark-component":"avatar-online-badge",role:"status","aria-label":l,style:{...s==="circle"?{left:`${o.x}px`,top:`${o.y}px`}:{right:"0px",bottom:"0px"}},className:m.cx("bg-success outline-surface absolute rounded-full",s==="circle"?"-translate-x-1/2 -translate-y-1/2":"translate-x-1/4 translate-y-1/4",["lg","xl","2xl"].includes(i)?m.cx("size-sz-12 outline-4"):m.cx("size-sz-8 outline-2")),...n})};C.displayName="AvatarOnlineBadge";const I=({asChild:e,children:n,className:t,...a})=>{const{shape:s,isOnline:l,onlineText:i,username:c}=v(),o=e?h.Slot:"div",u=l&&i?`${c} (${i})`:c;return x.jsx(o,{...!e&&{role:"img"},"aria-label":u,title:u,className:m.cx("group default:border-outline relative size-full overflow-hidden","focus-visible:u-outline",{"default:rounded-full":s==="circle","default:rounded-md":s==="square","hover:opacity-dim-1 cursor-pointer":e||a.onClick},t),...a,children:n})};I.displayName="AvatarUser";const M=({className:e,children:n,...t})=>{const{size:a,username:s}=v(),l=s?.charAt(0);return x.jsx("div",{"aria-hidden":!0,className:m.cx("absolute inset-0 flex size-full items-center justify-center","default:bg-neutral default:text-on-neutral",{"text-display-1":a==="2xl","text-display-2":["xl","lg"].includes(a),"text-display-3":a==="md","text-headline-2":a==="sm","text-body-2 font-bold":a==="xs"},e),...t,children:n||l})};M.displayName="AvatarPlaceholder";const f=z;f.Image=O;f.Action=S;f.OnlineBadge=C;f.User=I;f.Placeholder=M;exports.Avatar=f;
//# sourceMappingURL=index.js.map
