import { getLoginRequest, getSignInAuthProvider, getTokenRequest } from "./signInAuthProvider.mjs";
import { whitelistedPaths } from "./whitelistedPaths.internal.mjs";
//#region src/utilities/auth/authActions.ts
/**
* Hook providing auth "actions" such as login/logout
*/
const useLoginAction = () => loginRedirect;
const loginRedirect = () => {
	getSignInAuthProvider().loginRedirect(getLoginRequest());
};
function useLogoutAction() {
	return () => {
		const signInAuthProvider = getSignInAuthProvider();
		signInAuthProvider.logoutRedirect({ account: signInAuthProvider.getActiveAccount() });
	};
}
async function acquireAccessToken() {
	const signInAuthProvider = getSignInAuthProvider();
	const account = signInAuthProvider.getActiveAccount() ?? void 0;
	if (account) return signInAuthProvider.acquireTokenSilent({
		...getTokenRequest(),
		account
	}).then((response) => {
		return response.accessToken;
	}).catch(() => {
		if (!whitelistedPaths.includes(window.location.pathname)) signInAuthProvider.loginRedirect(getLoginRequest());
	});
}
//#endregion
export { acquireAccessToken, loginRedirect, useLoginAction, useLogoutAction };

//# sourceMappingURL=authActions.mjs.map