'use client';
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),F=require("react"),i=require("@heroui/react"),H=require("../../../hooks/use-auth.cjs"),J=require("../../../hooks/use-config.cjs"),K=require("../../../hooks/use-theme.cjs"),Q=e=>e&&e.__esModule?e:{default:e},V=Q(F);function W(e,o){if(e){const r=e.trim().split(" ");return r.length>=2?`${r[0][0]}${r[1][0]}`.toUpperCase():r[0][0]?.toUpperCase()||""}return o&&o[0]?.toUpperCase()||""}function B(e){switch(e?.toLowerCase()){case"owner":return"danger";case"admin":return"warning";case"member":return"primary";case"guest":return"secondary";default:return"default"}}function M(e){switch(e?.toLowerCase()){case"owner":return"Owner";case"admin":return"Admin";case"member":return"Member";case"guest":return"Guest";default:return e||""}}function X({userId:e,src:o,name:r,email:p,size:g="md",radius:h="full",showStatus:b=!1,isOnline:c=!1,fallback:v,className:x="",onClick:l,isClickable:u=!1,showOrganizationBadge:w=!1,role:s,color:j="default",isBordered:y=!1,isDisabled:n=!1,initials:N,icon:C,quality:R=80,useOrganizationColors:A=!1}){const{user:_,isOrganizationMember:I}=H.useAuth(),{components:$,organizationSettings:L}=J.useConfig(),{primaryColor:Y}=K.useTheme(),U=$.UserAvatar;if(U)return t.jsx(U,{userId:e,src:o,name:r,email:p,size:g,radius:h,showStatus:b,isOnline:c,fallback:v,className:x,onClick:l,isClickable:u,showOrganizationBadge:w,role:s,color:j,isBordered:y,isDisabled:n,initials:N,icon:C,quality:R,useOrganizationColors:A});const a=e?null:_,S=o||a?.profileImageUrl,q=r||a?.firstName&&a?.lastName?`${a.firstName} ${a.lastName}`:a?.username,T=p||a?.primaryEmailAddress,z=N||W(q,T),E=A&&L?.branding?.primaryColor?"primary":j,G=v||(z?t.jsx("span",{className:"font-medium text-inherit",children:z}):C||t.jsx("svg",{className:"w-full h-full text-default-400",fill:"currentColor",viewBox:"0 0 24 24",children:t.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"})})),P=V.default.useCallback(()=>{u&&l&&!n&&l()},[u,l,n]),m=b&&t.jsx(i.Badge,{content:"",color:c?"success":"default",shape:"circle",placement:"bottom-right",size:"sm",classNames:{badge:c?"border-2 border-white":"border-2 border-white bg-default-300"}}),d=w&&s&&I&&t.jsx(i.Badge,{content:M(s),color:B(s),variant:"flat",placement:"bottom-right",size:"sm",classNames:{badge:"text-xs px-1 py-0.5 min-w-fit"}}),f=t.jsx(i.Avatar,{src:S,name:q,size:g,radius:h,color:E,isBordered:y,isDisabled:n,fallback:G,classNames:{base:[x,u&&!n&&"cursor-pointer hover:opacity-80 transition-opacity",n&&"opacity-50 cursor-not-allowed"].filter(Boolean).join(" ")},onClick:P});return m&&d?t.jsxs("div",{className:"relative inline-block",children:[f,m,t.jsx("div",{className:"absolute -bottom-1 -right-1 transform translate-x-1/2",children:d})]}):m?t.jsx(i.Badge,{content:"",color:c?"success":"default",shape:"circle",placement:"bottom-right",size:"sm",classNames:{badge:c?"border-2 border-white":"border-2 border-white bg-default-300"},children:f}):d?t.jsx(i.Badge,{content:M(s),color:B(s),variant:"flat",placement:"bottom-right",size:"sm",classNames:{badge:"text-xs px-1 py-0.5 min-w-fit"},children:f}):f}exports.UserAvatar=X;
//# sourceMappingURL=user-avatar.cjs.map
