"use strict";(globalThis.webpackChunk_clerk_ui=globalThis.webpackChunk_clerk_ui||[]).push([["917"],{7399:function(e,t,n){n.r(t),n.d(t,{ImpersonationFab:()=>S});var i=n(1564),o=n(8095),r=n(4180),s=n(5074),a=n(9599),l=n(3264),c=n(8272),d=n(8920),u=n(78),p=n(8074),f=n(2861),m=n(1986),h=n(8691),g=n(6294),w=n(7591),$=n(9406);let b=({width:e,height:t,...n})=>{let{sx:o,...r}=n;return(0,i.Y)(c.fv,{elementDescriptor:d.$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:d.$z.impersonationFabIcon,icon:g.A,sx:e=>({color:e.colors.$white}),size:"lg"})})},v=({title:e,signOutText:t})=>{let{session:n}=(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,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:d.$z.impersonationFabTitle,variant:"buttonLarge",truncate:!0,localizationKey:e}),(0,i.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:n.id})})]})},x=()=>{let{session:e}=(0,r.wV)(),{t}=(0,u._)(),{parsedInternalTheme:n}=(0,p.K)(),a=(0,s.useRef)(null),l=e?.actor,h=e?.agent,g=n.sizes.$16,$="--cl-impersonation-fab-top",x="--cl-impersonation-fab-right",S=()=>{let e=a.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(x,"23px"),document.documentElement.style.setProperty($,"109px"))},y=s.useCallback(e=>{e.stopPropagation(),e.preventDefault();let t=a.current;if(!t)return;let n=`${window.innerWidth-t.offsetLeft-t.offsetWidth-e.movementX}px`;document.documentElement.style.setProperty(x,n),document.documentElement.style.setProperty($,`${t.offsetTop- -e.movementY}px`)},[]);if((0,s.useEffect)(()=>(window.addEventListener("resize",S),()=>{window.removeEventListener("resize",S)}),[]),!(l&&!h)||!e.user)return null;let z=(0,f.G)("impersonationFab.title",{identifier:(0,o.dS)(e.user)||(0,o.Cm)(e.user)}),D=t(z).length;return(0,i.Y)(m.Z,{children:(0,i.FD)(c.so,{ref:a,elementDescriptor:d.$z.impersonationFab,onPointerDown:()=>{window.addEventListener("pointermove",y),window.addEventListener("pointerup",()=>{window.removeEventListener("pointermove",y),S()},{once:!0})},align:"center",sx:e=>({touchAction:"none",position:"fixed",overflow:"hidden",top:`var(${$}, 109px)`,right:`var(${x}, 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 - ${g} - 2 * 23px), ${D}ch)`,[w.g.md]:{maxWidth:`min(calc(100vw - ${g} - 2 * 23px), ${D}ch)`},opacity:1},":hover #cl-impersonationEye":{transform:"rotate(-180deg)"}}),children:[(0,i.Y)(b,{id:"cl-impersonationEye",width:g,height:g,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)(v,{title:z,signOutText:(0,f.G)("impersonationFab.action__signOut")})})]})})},S=(0,l.G)(()=>(0,i.Y)($.S,{children:(0,i.Y)(x,{})}))},9599:function(e,t,n){n.d(t,{g:()=>r});var i=n(4180),o=n(4964);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()}}}}]);