/*! @azure/msal-react v3.0.17 2025-08-05 */ 'use strict'; import { useState, useEffect } from 'react'; import { InteractionStatus, AccountEntity } from '@azure/msal-browser'; import { useMsal } from './useMsal.js'; import { getAccountByIdentifiers } from '../utils/utilities.js'; /* * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ function getAccount(instance, accountIdentifiers) { if (!accountIdentifiers || (!accountIdentifiers.homeAccountId && !accountIdentifiers.localAccountId && !accountIdentifiers.username)) { // If no account identifiers are provided, return active account return instance.getActiveAccount(); } return getAccountByIdentifiers(instance.getAllAccounts(), accountIdentifiers); } /** * Given 1 or more accountIdentifiers, returns the Account object if the user is signed-in * @param accountIdentifiers */ function useAccount(accountIdentifiers) { const { instance, inProgress, logger } = useMsal(); const [account, setAccount] = useState(() => { if (inProgress === InteractionStatus.Startup) { return null; } else { return getAccount(instance, accountIdentifiers); } }); useEffect(() => { if (inProgress !== InteractionStatus.Startup) { setAccount((currentAccount) => { const nextAccount = getAccount(instance, accountIdentifiers); if (!AccountEntity.accountInfoIsEqual(currentAccount, nextAccount, true)) { logger.info("useAccount - Updating account"); return nextAccount; } return currentAccount; }); } }, [inProgress, accountIdentifiers, instance, logger]); return account; } export { useAccount }; //# sourceMappingURL=useAccount.js.map