"use strict";(globalThis.webpackChunk_clerk_ui=globalThis.webpackChunk_clerk_ui||[]).push([["99"],{33597(e,n,o){o.r(n),o.d(n,{UserButton:()=>O});var r=o(59763),t=o(59701),l=o(17308),i=o(57494),s=o(33592),a=o(9203),c=o(41522),d=o(92484),u=o(42959),p=o(58316),h=o(69094),Y=o(45682),m=o(91868),g=o(26447),k=o(3623),C=o(27847);let f=t.forwardRef((e,n)=>{let{close:o,...t}=e,l=()=>null==o?void 0:o(!1),{session:i}=(0,u.wV)(),a=(0,s.Y)(),{__experimental_asStandalone:c}=a,{authConfig:d}=(0,m.O)(),{user:f}=(0,u.Jd)(),{handleAddAccountClicked:B,handleManageAccountClicked:$,handleSessionClicked:b,handleSignOutAllClicked:v,handleSignOutSessionClicked:D,handleUserProfileActionClicked:x,otherSessions:S}=(0,C.u)({...a,actionCompleteCallback:l,user:f});return(0,r.Y)(h.M,{elementDescriptor:g.$z.userButtonPopoverRootBox,children:(0,r.FD)(p.Y.Root,{elementDescriptor:g.$z.userButtonPopoverCard,ref:n,role:"dialog","aria-label":"User button popover",shouldEntryAnimate:!c,...t,children:[(0,r.FD)(p.Y.Content,{elementDescriptor:g.$z.userButtonPopoverMain,children:[(0,r.Y)(Y.c,{elementId:"userButton",user:f,sx:e=>({width:"100%",padding:"".concat(e.space.$4," ").concat(e.space.$5)})}),d.singleSessionMode?(0,r.Y)(k.iR,{handleManageAccountClicked:$,handleSignOutSessionClicked:D,handleUserProfileActionClicked:x,session:i,completedCallback:l}):(0,r.Y)(k.pS,{session:i,otherSessions:S,handleManageAccountClicked:$,handleSignOutSessionClicked:D,handleSessionClicked:b,handleAddAccountClicked:B,handleUserProfileActionClicked:x,completedCallback:l})]}),(0,r.Y)(p.Y.Footer,{elementDescriptor:g.$z.userButtonPopoverFooter,children:!d.singleSessionMode&&S.length>0&&(0,r.Y)(k.ww,{handleSignOutAllClicked:v})})]})})});var B=o(12983),$=o(37353),b=o(84722),v=o(12597),D=o(78342),x=o(43974);let S=e=>{let{showName:n}=e,{user:o}=(0,u.Jd)();return o&&n?(0,r.Y)(v.EY,{variant:"subtitle",as:"span",elementDescriptor:g.$z.userButtonOuterIdentifier,sx:[e=>({paddingInlineStart:e.space.$2})],children:(0,x.dS)(o)||(0,x.Cm)(o)}):null},z=(0,$.H)((0,t.forwardRef)((e,n)=>{let{sx:o,...t}=e,{user:l}=(0,u.Jd)(),{showName:i}=(0,s.Y)(),{t:a}=(0,b._)();return(0,r.Y)(v.$n,{elementDescriptor:g.$z.userButtonTrigger,variant:"roundWrapper",sx:[e=>({borderRadius:i?e.radii.$md:e.radii.$circle,color:e.colors.$colorForeground}),o],ref:n,"aria-label":"".concat(a(e.isOpen?(0,D.G)("userButton.action__closeUserMenu"):(0,D.G)("userButton.action__openUserMenu"))),"aria-expanded":e.isOpen,"aria-haspopup":"dialog",...t,children:(0,r.FD)(v.so,{elementDescriptor:g.$z.userButtonBox,isOpen:e.isOpen,align:"center",as:"span",gap:2,children:[(0,r.Y)(S,{showName:i}),(0,r.Y)(B.H,{boxElementDescriptor:g.$z.userButtonAvatarBox,imageElementDescriptor:g.$z.userButtonAvatarImage,...l,size:e=>e.sizes.$7})]})})})),A=(0,l.P4)(e=>{let{children:n}=e,{defaultOpen:o}=(0,s.Y)(),{floating:l,reference:a,styles:c,toggle:u,isOpen:p,nodeId:h,context:Y}=(0,d.f)({defaultOpen:o,placement:"bottom-end",offset:8}),m=(0,t.useId)();return(0,r.FD)(r.FK,{children:[(0,r.Y)(z,{ref:a,onClick:u,isOpen:p,"aria-controls":p?m:void 0,"aria-expanded":p}),(0,r.Y)(i.A,{nodeId:h,context:Y,isOpen:p,children:(0,t.cloneElement)(n,{id:m,close:u,ref:l,style:c})})]})}),O=(0,a.G)((0,l.dm)(()=>{let{__experimental_asStandalone:e}=(0,s.Y)();return(0,r.Y)(c.n.Root,{flow:"userButton",sx:{display:"inline-flex"},children:e?(0,r.Y)(f,{close:"function"==typeof e?e:void 0}):(0,r.Y)(A,{children:(0,r.Y)(f,{})})})}))}}]);