// Metro module 5523 (f5524). import AuthorizedAppsStore, { FetchState } from "./AuthorizedAppsStore"; import { Endpoints } from "../../Constants"; import { BatchInvocationManager, BatchInvocationManagerResetError } from "../../_bundle/Timeout"; import Dispatcher from "../../Dispatcher"; import { HTTP } from "../../_bundle/sendRequest"; let c3395_7, fetchAuthorizedApps; const tokensToAppTokensMap = function tokensToAppTokensMap(body, applicationIds) { const r2 = Object; let r19 = applicationIds == null ? void 0 : applicationIds.map((item) => [item, null]); if (r19 == null) { r19 = []; } const r22 = r2.fromEntries(r19); for (const item of body) { r22[item.application.id] = item; } return r22; }; fetchAuthorizedApps = async function fetchAuthorizedApps(application_ids) { const applicationIds = application_ids; await HTTP.get({ url: Endpoints.OAUTH2_TOKENS, oldFormErrors: true, rejectWithError: true, query: { application_ids } }).then((result) => Dispatcher.dispatch({ type: "USER_AUTHORIZED_APPS_UPDATE", isFullFetch: applicationIds == null, tokens: tokensToAppTokensMap(result.body, applicationIds) }), () => Dispatcher.dispatch({ type: "USER_AUTHORIZED_APPS_REQUEST_FAILED", request: applicationIds == null ? { type: "full" } : { type: "partial", applicationIds } })); }; c3395_7 = new BatchInvocationManager(fetchAuthorizedApps, { predicate: (a0) => AuthorizedAppsStore.getFetchStateForApplication(a0) !== FetchState.FETCHING, onQueued: (a0) => Dispatcher.dispatch({ type: "USER_AUTHORIZED_APPS_REQUEST", request: { type: "partial", applicationIds: a0 } }), onCancelled: (a0) => Dispatcher.dispatch({ type: "USER_AUTHORIZED_APPS_REQUEST_CANCELLED", applicationIds: a0 }) }); const r41 = { fetch: (a0) => { if (AuthorizedAppsStore.getFetchState() !== FetchState.FETCHING) { if (a0 != null) { c3395_7.queue(a0).catch((error) => { if (error instanceof BatchInvocationManagerResetError) { return void 0; } throw error; }); } else { c3395_7.reset(); Dispatcher.dispatch({ type: "USER_AUTHORIZED_APPS_REQUEST", request: { type: "full" } }); fetchAuthorizedApps(); } } }, delete: function(a0) { HTTP.del({ url: Endpoints.OAUTH2_TOKEN(a0), oldFormErrors: true, rejectWithError: true }).then(() => { this.fetch(); }); } }; export default r41;