"use strict";(globalThis.webpackChunk_clerk_ui=globalThis.webpackChunk_clerk_ui||[]).push([["99"],{6240:function(e,n,r){r.r(n),r.d(n,{UserButton:()=>w});var o=r(4518),t=r(630),i=r.n(t),l=r(3269),s=r(4373),a=r(9233),d=r(3264),c=r(4607),u=r(1577),p=r(8628),h=r(9972),Y=r(1005),m=r(9345),g=r(7697),f=r(8920),$=r(1052),k=r(2540);let C=i().forwardRef((e,n)=>{let{close:r,...t}=e,i=()=>r?.(!1),{session:l}=(0,p.wV)(),s=(0,a.Y)(),{__experimental_asStandalone:d}=s,{authConfig:c}=(0,g.O)(),{user:u}=(0,p.Jd)(),{handleAddAccountClicked:C,handleManageAccountClicked:B,handleSessionClicked:b,handleSignOutAllClicked:v,handleSignOutSessionClicked:D,handleUserProfileActionClicked:x,otherSessions:z}=(0,k.u)({...s,actionCompleteCallback:i,user:u});return(0,o.Y)(Y.M,{elementDescriptor:f.$z.userButtonPopoverRootBox,children:(0,o.FD)(h.Y.Root,{elementDescriptor:f.$z.userButtonPopoverCard,ref:n,role:"dialog","aria-label":"User button popover",shouldEntryAnimate:!d,...t,children:[(0,o.FD)(h.Y.Content,{elementDescriptor:f.$z.userButtonPopoverMain,children:[(0,o.Y)(m.c,{elementId:"userButton",user:u,sx:e=>({width:"100%",padding:`${e.space.$4} ${e.space.$5}`})}),c.singleSessionMode?(0,o.Y)($.iR,{handleManageAccountClicked:B,handleSignOutSessionClicked:D,handleUserProfileActionClicked:x,session:l,completedCallback:i}):(0,o.Y)($.pS,{session:l,otherSessions:z,handleManageAccountClicked:B,handleSignOutSessionClicked:D,handleSessionClicked:b,handleAddAccountClicked:C,handleUserProfileActionClicked:x,completedCallback:i})]}),(0,o.Y)(h.Y.Footer,{elementDescriptor:f.$z.userButtonPopoverFooter,children:!c.singleSessionMode&&z.length>0&&(0,o.Y)($.ww,{handleSignOutAllClicked:v})})]})})});var B=r(9538),b=r(1778),v=r(78),D=r(8272),x=r(2861),z=r(8095);let A=({showName:e})=>{let{user:n}=(0,p.Jd)();return n&&e?(0,o.Y)(D.EY,{variant:"subtitle",as:"span",elementDescriptor:f.$z.userButtonOuterIdentifier,sx:[e=>({paddingLeft:e.space.$2})],children:(0,z.dS)(n)||(0,z.Cm)(n)}):null},O=(0,b.H)((0,t.forwardRef)((e,n)=>{let{sx:r,...t}=e,{user:i}=(0,p.Jd)(),{showName:l}=(0,a.Y)(),{t:s}=(0,v._)();return(0,o.Y)(D.$n,{elementDescriptor:f.$z.userButtonTrigger,variant:"roundWrapper",sx:[e=>({borderRadius:l?e.radii.$md:e.radii.$circle,color:e.colors.$colorForeground}),r],ref:n,"aria-label":`${s(e.isOpen?(0,x.G)("userButton.action__closeUserMenu"):(0,x.G)("userButton.action__openUserMenu"))}`,"aria-expanded":e.isOpen,"aria-haspopup":"dialog",...t,children:(0,o.FD)(D.so,{elementDescriptor:f.$z.userButtonBox,isOpen:e.isOpen,align:"center",as:"span",gap:2,children:[(0,o.Y)(A,{showName:l}),(0,o.Y)(B.H,{boxElementDescriptor:f.$z.userButtonAvatarBox,imageElementDescriptor:f.$z.userButtonAvatarImage,...i,size:e=>e.sizes.$7})]})})})),S=(0,l.P4)(({children:e})=>{let{defaultOpen:n}=(0,a.Y)(),{floating:r,reference:i,styles:l,toggle:d,isOpen:c,nodeId:p,context:h}=(0,u.f)({defaultOpen:n,placement:"bottom-end",offset:8}),Y=(0,t.useId)();return(0,o.FD)(o.FK,{children:[(0,o.Y)(O,{ref:i,onClick:d,isOpen:c,"aria-controls":c?Y:void 0,"aria-expanded":c}),(0,o.Y)(s.A,{nodeId:p,context:h,isOpen:c,children:(0,t.cloneElement)(e,{id:Y,close:d,ref:r,style:l})})]})}),w=(0,d.G)((0,l.dm)(()=>{let{__experimental_asStandalone:e}=(0,a.Y)();return(0,o.Y)(c.n.Root,{flow:"userButton",sx:{display:"inline-flex"},children:e?(0,o.Y)(C,{close:"function"==typeof e?e:void 0}):(0,o.Y)(S,{children:(0,o.Y)(C,{})})})}))}}]);