1import{r as x,i as f,j as t,bC as r,az as p,G as b,aI as g,aD as w}from"./vendor-BeA4siBz.js";import{n as j,u as k,a0 as N,a1 as y,B as v,N as z,f as C,O as S,q as B}from"./index-C2NQ_9nj.js";const d="linked-account-banner-minimized";function O(){const{user:e}=j(),{toast:o}=k(),[a,m]=x.useState(()=>{try{return sessionStorage.getItem(d)==="1"}catch{return!1}}),i=e==null?void 0:e.identityContext,n=(i==null?void 0:i.mode)==="linked_account"&&i.subjectUserId===(e==null?void 0:e.id),u=N("linked-account",n&&!a,40),h=y("linked-account-pill",n&&a,30),l=s=>{m(s);try{sessionStorage.setItem(d,s?"1":"0")}catch{}},c=f({mutationFn:async()=>{const s=await z();if(!s.verified)throw new Error(s.reason??"Could not safely detach browser notifications");return(await C("POST","/api/linked-accounts/switch-back")).json()},onSuccess:()=>{o({title:"Switched back to your account"}),S("/account/legacy?tab=linked-accounts")},onError:s=>{B.invalidateQueries({queryKey:["/api/user"]}),o({title:"Failed to switch back",description:s.message,variant:"destructive"})}});return n?a?t.jsxs("button",{onClick:()=>l(!1),className:"fixed left-4 z-[60] flex items-center gap-1.5 rounded-full bg-blue-600 text-white pl-2.5 pr-3 py-1.5 shadow-lg hover:bg-blue-700 transition-colors text-xs font-semibold",style:{bottom:h},title:`Viewing linked account ${(e==null?void 0:e.fullName)||(e==null?void 0:e.username)} â click to expand`,"data-testid":"button-expand-linked-account",children:[t.jsx(r,{className:"h-3.5 w-3.5"}),t.jsx("span",{children:"Linked"}),t.jsx(p,{className:"h-3 w-3 opacity-80"})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"h-10"}),t.jsx("div",{className:"fixed left-0 right-0 top-0 z-[59] bg-blue-600",style:{height:"env(safe-area-inset-top, 0px)"}}),t.jsxs("div",{className:"fixed left-0 right-0 z-[60] bg-blue-600 text-white px-2 sm:px-4 py-2 flex items-center justify-between gap-2 shadow-lg h-10",style:{to
1p:u},children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx(r,{className:"h-4 w-4 shrink-0"}),t.jsxs("span",{className:"text-sm font-medium truncate",children:["Viewing linked account: ",t.jsx("strong",{children:(e==null?void 0:e.fullName)||(e==null?void 0:e.username)}),t.jsxs("span",{className:"hidden md:inline",children:[" (",e==null?void 0:e.email,")"]})]})]}),t.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[t.jsxs(v,{size:"sm",variant:"secondary",className:"bg-white text-blue-700 hover:bg-blue-50 h-7 text-xs",onClick:()=>c.mutate(),disabled:c.isPending,"data-testid":"button-linked-switch-back",children:[c.isPending?t.jsx(b,{className:"h-3 w-3 animate-spin mr-1"}):t.jsx(g,{className:"h-3 w-3 mr-1"}),"Switch Back"]}),t.jsx("button",{onClick:()=>l(!0),className:"h-7 w-7 flex items-center justify-center rounded hover:bg-blue-700 transition-colors",title:"Minimize banner","data-testid":"button-minimize-linked-account",children:t.jsx(w,{className:"h-4 w-4"})})]})]})]}):null}export{O as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.