"use strict";(globalThis.webpackChunk_clerk_ui=globalThis.webpackChunk_clerk_ui||[]).push([["917"],{7399:function(e,t,i){i.r(t),i.d(t,{ImpersonationFab:()=>S});var n=i(4518),o=i(8095),r=i(8628),s=i(5074),a=i(9599),l=i(3264),c=i(8272),d=i(8920),u=i(78),p=i(8074),f=i(2861),m=i(1986),h=i(8691),g=i(6294),w=i(7591),$=i(9406);let b=({width:e,height:t,...i})=>{let{sx:o,...r}=i;return(0,n.Y)(c.fv,{elementDescriptor:d.$z.impersonationFabIconContainer,center:!0,sx:[i=>({width:e,height:t,backgroundColor:i.colors.$danger500,borderRadius:i.radii.$circle}),o],...r,children:(0,n.Y)(c.In,{elementDescriptor:d.$z.impersonationFabIcon,icon:g.A,sx:e=>({color:e.colors.$white}),size:"lg"})})},v=({title:e,signOutText:t})=>{let{session:i}=(0,r.wV)(),{user:o}=(0,r.Jd)(),{signOut:s}=(0,r.ho)(),{otherSessions:l}=(0,h.z)({user:o}),{navigateAfterSignOut:u,navigateAfterMultiSessionSingleSignOutUrl:p}=(0,a.g)();return(0,n.FD)(c.fv,{sx:e=>({width:"100%",paddingLeft:e.sizes.$4,paddingRight:e.sizes.$6,whiteSpace:"nowrap"}),children:[(0,n.Y)(c.EY,{colorScheme:"secondary",elementDescriptor:d.$z.impersonationFabTitle,variant:"buttonLarge",truncate:!0,localizationKey:e}),(0,n.Y)(c.N_,{variant:"buttonLarge",elementDescriptor:d.$z.impersonationFabActionLink,sx:e=>({alignSelf:"flex-start",color:e.colors.$primary500,":hover":{cursor:"pointer"}}),localizationKey:t,onClick:()=>0===l.length?s(u):s(p,{sessionId:i.id})})]})},x=()=>{let{session:e}=(0,r.wV)(),{t}=(0,u._)(),{parsedInternalTheme:i}=(0,p.K)(),a=(0,s.useRef)(null),l=e?.actor,h=i.sizes.$16,g="--cl-impersonation-fab-top",$="--cl-impersonation-fab-right",x=()=>{let e=a.current;if(!e)return;let t=window.innerWidth-e.offsetLeft-e.offsetWidth,i=window.innerHeight-e.offsetTop-e.offsetHeight;[e.offsetLeft,t,e.offsetTop,i].some(e=>e<0)&&(document.documentElement.style.setProperty($,"23px"),document.documentElement.style.setProperty(g,"109px"))},S=s.useCallback(e=>{e.stopPropagation(),e.preventDefault();let t=a.current;if(!t)return;let i=`${window.innerWidth-t.offsetLeft-t.offsetWidth-e.movementX}px`;document.documentElement.style.setProperty($,i),document.documentElement.style.setProperty(g,`${t.offsetTop- -e.movementY}px`)},[]);if((0,s.useEffect)(()=>(window.addEventListener("resize",x),()=>{window.removeEventListener("resize",x)}),[]),!l||!e.user)return null;let y=(0,f.G)("impersonationFab.title",{identifier:(0,o.dS)(e.user)||(0,o.Cm)(e.user)}),z=t(y).length;return(0,n.Y)(m.Z,{children:(0,n.FD)(c.so,{ref:a,elementDescriptor:d.$z.impersonationFab,onPointerDown:()=>{window.addEventListener("pointermove",S),window.addEventListener("pointerup",()=>{window.removeEventListener("pointermove",S),x()},{once:!0})},align:"center",sx:e=>({touchAction:"none",position:"fixed",overflow:"hidden",top:`var(${g}, 109px)`,right:`var(${$}, 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 - ${h} - 2 * 23px), ${z}ch)`,[w.g.md]:{maxWidth:`min(calc(100vw - ${h} - 2 * 23px), ${z}ch)`},opacity:1},":hover #cl-impersonationEye":{transform:"rotate(-180deg)"}}),children:[(0,n.Y)(b,{id:"cl-impersonationEye",width:h,height:h,sx:e=>({transition:`transform ${e.transitionDuration.$slowest} ease`})}),(0,n.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,n.Y)(v,{title:y,signOutText:(0,f.G)("impersonationFab.action__signOut")})})]})})},S=(0,l.G)(()=>(0,n.Y)($.S,{children:(0,n.Y)(x,{})}))},9599:function(e,t,i){i.d(t,{g:()=>r});var n=i(8628),o=i(4964);let r=()=>{let{navigate:e}=(0,o.r)(),t=(0,n.ho)();return{navigateAfterSignOut:()=>e(t.buildAfterSignOutUrl()),navigateAfterMultiSessionSingleSignOutUrl:()=>e(t.buildAfterMultiSessionSingleSignOutUrl()),afterSignOutUrl:t.buildAfterSignOutUrl(),afterMultiSessionSingleSignOutUrl:t.buildAfterMultiSessionSingleSignOutUrl()}}}}]);