import{r as c,R as l,X as i,t as p,j as s}from"./index-B-YXshIJ.js";import{d}from"./default-profile-pic-B1WNOWFq.js";import{U as g}from"./user-DEWqbyPD.js";import{S as h}from"./settings-CXc2CXGp.js";function u(){return u=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=n[t])}return e},u.apply(this,arguments)}function x(e,r){if(e==null)return{};var n=y(e,r),t,o;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++)t=a[o],!(r.indexOf(t)>=0)&&Object.prototype.propertyIsEnumerable.call(e,t)&&(n[t]=e[t])}return n}function y(e,r){if(e==null)return{};var n={},t=Object.keys(e),o,a;for(a=0;a<t.length;a++)o=t[a],!(r.indexOf(o)>=0)&&(n[o]=e[o]);return n}var f=c.forwardRef(function(e,r){var n=e.color,t=n===void 0?"currentColor":n,o=e.size,a=o===void 0?24:o,m=x(e,["color","size"]);return l.createElement("svg",u({ref:r,xmlns:"http://www.w3.org/2000/svg",width:a,height:a,viewBox:"0 0 24 24",fill:"none",stroke:t,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},m),l.createElement("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),l.createElement("polyline",{points:"16 17 21 12 16 7"}),l.createElement("line",{x1:"21",y1:"12",x2:"9",y2:"12"}))});f.propTypes={color:i.string,size:i.oneOfType([i.string,i.number])};f.displayName="LogOut";const b=f,k=()=>{const[e,r]=c.useState(!1),n=c.useCallback(async()=>((await fetch("/api/logout",{method:"GET",headers:{"Content-Type":"application/json"}})).ok&&(window.location.href="/?auth=true"),null),[]),t=p.auth.verifySession.useQuery();return t.data?s.jsxs("div",{className:"relative inline-block text-left",role:"button",tabIndex:0,onClick:()=>r(!e),onKeyDown:o=>{o.key==="Enter"&&r(!0)},onBlur:()=>r(!1),children:[s.jsx("div",{className:"flex items-center",children:s.jsx("div",{className:"flex-shrink-0",children:s.jsx("img",{className:"h-10 w-10 rounded-full",src:d,alt:"User Avatar"})})}),e?s.jsxs("div",{className:"absolute right-0 p-2 w-48 bg-white rounded-md shadow-xl z-10",children:[s.jsxs("div",{className:"text-gray-700 block py-2 text-sm w-full text-left hover:bg-gray-100",children:[s.jsx(g,{className:"w-4 h-4 inline-block mr-2"}),t.data.email]}),s.jsxs("button",{className:"text-gray-700 block py-2 text-sm w-full text-left hover:bg-gray-100",type:"button",title:"settings","aria-label":"Organization Settings",onMouseDown:()=>{window.location.href="/demo/settings/personal?auth=true"},children:[s.jsx(h,{className:"w-4 h-4 inline-block mr-2"}),"Settings"]}),s.jsx("hr",{className:"my-2"}),s.jsxs("button",{type:"button",className:"text-gray-700 block py-2 text-sm w-full text-left hover:bg-gray-100",onMouseDown:n,children:[s.jsx(b,{className:"w-4 h-4 inline-block mr-2"}),"Logout"]})]}):null]}):null};export{k as default};
