// Metro module 11523 (f11524). import { useEffect } from "react"; import ApplicationStore from "../../applications/ApplicationStore"; import AuthorizedAppsStore, { FetchState } from "../../oauth2/AuthorizedAppsStore"; import { useStateFromStoresObject, useStateFromStores } from "../../../_bundle/Module589"; import AuthorizedAppsActionCreators from "../../oauth2/AuthorizedAppsActionCreators"; import ApplicationActionCreators from "../../applications/ApplicationActionCreators"; export default function useRequiredLinkedLobbyApplicationAuthorization(a0) { const r10 = a0?.require_application_authorization ? a0.application_id : null; let authorizationsFetchState, stateFromStores, stateFromStores2; const application_id = r10; const stateFromStoresObject = useStateFromStoresObject([AuthorizedAppsStore], () => ({ authorizationsFetchState: AuthorizedAppsStore.getFetchState(), applicationOAuth2Token: AuthorizedAppsStore.getNewestTokenForApplication(application_id) })); authorizationsFetchState = stateFromStoresObject.authorizationsFetchState; const applicationOAuth2Token = stateFromStoresObject.applicationOAuth2Token; stateFromStores = useStateFromStores([ApplicationStore], () => ApplicationStore.getApplication(application_id)); let r33 = useStateFromStores([ApplicationStore], () => ApplicationStore.getApplication(stateFromStores?.parentId)); stateFromStores2 = r33; useEffect(() => { if (application_id != null && authorizationsFetchState === FetchState.NOT_FETCHED) { AuthorizedAppsActionCreators.fetch(); } }, [authorizationsFetchState, application_id]); useEffect(() => { if (application_id != null && stateFromStores == null && authorizationsFetchState === FetchState.FETCHED) { ApplicationActionCreators.fetchApplications([application_id], false); } }, [application_id, applicationOAuth2Token, authorizationsFetchState, stateFromStores]); useEffect(() => { if (stateFromStores != null && stateFromStores.parentId != null && stateFromStores2 == null && authorizationsFetchState === FetchState.FETCHED) { ApplicationActionCreators.fetchApplications([stateFromStores.parentId], false); } }, [stateFromStores, authorizationsFetchState, stateFromStores2]); const r44 = stateFromStores != null && (stateFromStores.parentId == null || stateFromStores2 != null); const showLinkedLobbyApplicationLoadingIndicator = application_id != null && (authorizationsFetchState !== FetchState.FETCHED || stateFromStores == null || !r44); const r51 = applicationOAuth2Token == null; let requiredLinkedLobbyApplication = null; if (r51) { const r53 = stateFromStores != null; requiredLinkedLobbyApplication = null; if (r53) { requiredLinkedLobbyApplication = null; if (r44) { if (stateFromStores2 == null) { r33 = stateFromStores; } requiredLinkedLobbyApplication = r33; } } } return { showLinkedLobbyApplicationLoadingIndicator, requiredLinkedLobbyApplication }; };