1import{o as e,s as t}from"./CBu2IYZT.js";import{g as n}from"./Ib1jYPSS.js";import{t as r}from"./Cd0R9atH.js";var i=new Set([`interaction_required`,`login_required`,`consent_required`,`timed_out`,`monitor_window_timeout`,`token_renewal_error`,`no_tokens_found`,`invalid_grant`]);function a(e){if(!e||typeof e!=`object`)return String(e??`Microsoft sign-in failed`);let t=e;return t.message??t.errorMessage??t.errorCode??`Microsoft sign-in failed`}function o(e){if(!e||typeof e!=`object`)return!1;let t=e;if(t.errorCode&&i.has(t.errorCode))return!0;let n=(t.message??``).toLowerCase();return n.includes(`timed_out`)||n.includes(`interaction_required`)||n.includes(`login_required`)||n.includes(`consent_required`)||n.includes(`token renewal`)||n.includes(`no_tokens_found`)}function s(){let i=t(),{$msal:s}=e(),c=i.public.graphScopes,l=r(`msal-account`,()=>null),u=r(`msal-redirect-error`,()=>null),d=r(`msal-session-invalid`,()=>!1),f=r(`msal-token-error`,()=>null),p=n(()=>!!i.public.azureClientId),m=n(()=>s),h=n(()=>l.value??m.value?.getActiveAccount()??m.value?.getAllAccounts()[0]??null),g=n(()=>!d.value&&!!h.value),_=n(()=>d.value&&!!h.value),v=null;function y(){d.value=!1,f.value=null}function b(e){o(e)&&(d.value=!0,f.value=a(e))}async function x(){if(!m.value)throw Error(`Microsoft auth is not configured`);y(),await m.value.loginRedirect({scopes:c})}async function S(){let e=h.value;!m.value||!e||(y(),await m.value.logoutRedirect({account:e}))}async function C(){if(!m.value)throw Error(`Microsoft auth is not configured`);let e=m.value.getActiveAccount()??m.value.getAllAccounts()[0]??null;if(!e)throw Error(`Not signed in to Microsoft`);try{let t=await m.value.acquireTokenSilent({account:e,scopes:c});if(!t.accessToken)throw Error(`No access token`);return y(),t.accessToken}catch(e){throw b(e),e}}async function w(){return v||(v=C().finally(()=>{v=null}),v)}return{account:h,isSignedIn:g,needsReauth:_,sessionInvalid:d,tokenError:f,isConfigured:p,login:x,logout:S,getAccessToken:C,verifySession:w,clearSessionError:y,authRedirectError:u}}export{s as t};
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.