"use strict";(globalThis.webpackChunk_clerk_ui=globalThis.webpackChunk_clerk_ui||[]).push([["917"],{3014(e,t,n){n.r(t),n.d(t,{ImpersonationFab:()=>y});var i=n(9763),o=n(3974),r=n(2959),s=n(630),a=n.n(s),l=n(9832),d=n(9203),c=n(2597),u=n(6447),p=n(4722),m=n(9735),f=n(8342),h=n(4883),g=n(4672),w=n(6069),$=n(4260),b=n(4629);let v=({width:e,height:t,...n})=>{let{sx:o,...r}=n;return(0,i.Y)(c.fv,{elementDescriptor:u.$z.impersonationFabIconContainer,center:!0,sx:[n=>({width:e,height:t,backgroundColor:n.colors.$danger500,borderRadius:n.radii.$circle}),o],...r,children:(0,i.Y)(c.In,{elementDescriptor:u.$z.impersonationFabIcon,icon:w.A,sx:e=>({color:e.colors.$white}),size:"lg"})})},x=({title:e,signOutText:t})=>{let{session:n}=(0,r.wV)(),{user:o}=(0,r.Jd)(),{signOut:s}=(0,r.ho)(),{otherSessions:a}=(0,g.z)({user:o}),{navigateAfterSignOut:d,navigateAfterMultiSessionSingleSignOutUrl:p}=(0,l.g)();return(0,i.FD)(c.fv,{sx:e=>({width:"100%",paddingInlineStart:e.sizes.$4,paddingInlineEnd:e.sizes.$6,whiteSpace:"nowrap"}),children:[(0,i.Y)(c.EY,{colorScheme:"secondary",elementDescriptor:u.$z.impersonationFabTitle,variant:"buttonLarge",truncate:!0,localizationKey:e}),(0,i.Y)(c.N_,{variant:"buttonLarge",elementDescriptor:u.$z.impersonationFabActionLink,sx:e=>({alignSelf:"flex-start",color:e.colors.$primary500,":hover":{cursor:"pointer"}}),localizationKey:t,onClick:()=>0===a.length?s(d):s(p,{sessionId:n.id})})]})},S=()=>{let{session:e}=(0,r.wV)(),{t}=(0,p._)(),{parsedInternalTheme:n}=(0,m.K)(),l=(0,s.useRef)(null),d=e?.actor,g=e?.agent,w=n.sizes.$16,b="--cl-impersonation-fab-top",S="--cl-impersonation-fab-right",y=()=>{let e=l.current;if(!e)return;let t=window.innerWidth-e.offsetLeft-e.offsetWidth,n=window.innerHeight-e.offsetTop-e.offsetHeight;[e.offsetLeft,t,e.offsetTop,n].some(e=>e<0)&&(document.documentElement.style.setProperty(S,"23px"),document.documentElement.style.setProperty(b,"109px"))},z=a().useCallback(e=>{e.stopPropagation(),e.preventDefault();let t=l.current;if(!t)return;let n=`${window.innerWidth-t.offsetLeft-t.offsetWidth-e.movementX}px`;document.documentElement.style.setProperty(S,n),document.documentElement.style.setProperty(b,`${t.offsetTop- -e.movementY}px`)},[]);if((0,s.useEffect)(()=>(window.addEventListener("resize",y),()=>{window.removeEventListener("resize",y)}),[]),!(d&&!g)||!e.user)return null;let D=(0,f.G)("impersonationFab.title",{identifier:(0,o.dS)(e.user)||(0,o.Cm)(e.user)}),E=t(D).length;return(0,i.Y)(h.Z,{children:(0,i.FD)(c.so,{ref:l,elementDescriptor:u.$z.impersonationFab,onPointerDown:()=>{window.addEventListener("pointermove",z),window.addEventListener("pointerup",()=>{window.removeEventListener("pointermove",z),y()},{once:!0})},align:"center",sx:e=>({touchAction:"none",position:"fixed",overflow:"hidden",top:`var(${b}, 109px)`,right:`var(${S}, 23px)`,zIndex:e.zIndices.$fab,boxShadow:e.shadows.$fabShadow,borderRadius:e.radii.$halfHeight,backgroundColor:e.colors.$white,fontFamily:e.fonts.$main,":hover":{cursor:"grab"},":hover #cl-impersonationText":{transition:`max-width ${e.transitionDuration.$slowest} ease, opacity ${e.transitionDuration.$slower} ease ${e.transitionDuration.$slowest}`,maxWidth:`min(calc(50vw - ${w} - 2 * 23px), ${E}ch)`,[$.g.md]:{maxWidth:`min(calc(100vw - ${w} - 2 * 23px), ${E}ch)`},opacity:1},":hover #cl-impersonationEye":{transform:"rotate(-180deg)"}}),children:[(0,i.Y)(v,{id:"cl-impersonationEye",width:w,height:w,sx:e=>({transition:`transform ${e.transitionDuration.$slowest} ease`})}),(0,i.Y)(c.so,{id:"cl-impersonationText",sx:e=>({transition:`max-width ${e.transitionDuration.$slowest} ease, opacity ${e.transitionDuration.$fast} ease`,maxWidth:"0px",opacity:0}),children:(0,i.Y)(x,{title:D,signOutText:(0,f.G)("impersonationFab.action__signOut")})})]})})},y=(0,d.G)(()=>(0,i.Y)(b.S,{children:(0,i.Y)(S,{})}))},9832(e,t,n){n.d(t,{g:()=>r});var i=n(2959),o=n(8029);let r=()=>{let{navigate:e}=(0,o.r)(),t=(0,i.ho)();return{navigateAfterSignOut:()=>e(t.buildAfterSignOutUrl()),navigateAfterMultiSessionSingleSignOutUrl:()=>e(t.buildAfterMultiSessionSingleSignOutUrl()),afterSignOutUrl:t.buildAfterSignOutUrl(),afterMultiSessionSingleSignOutUrl:t.buildAfterMultiSessionSingleSignOutUrl()}}}}]);