import { F as a, e as I, u as w, f as T, g as u, A as i, W as p } from "./FetchConfigsUtils-476a602b.mjs";
import { useCallback as c } from "react";
const h = {
  playerPortalConfigData: null,
  playerPortalConfigError: null,
  playerPortalConfigFetchStatus: a.IDLE,
  launcherData: null,
  launcherError: null,
  launcherFetchStatus: a.IDLE,
  paymentData: null,
  paymentError: null,
  paymentFetchStatus: a.IDLE,
  twitchDropData: null,
  twitchDropGamesData: null,
  twitchDropError: null,
  twitchDropFetchStatus: a.IDLE,
  supportData: null,
  supportError: null,
  supportFetchStatus: a.IDLE
}, d = I(h);
function G() {
  const [o] = w(), [E, n] = T(d), y = c(() => {
    n(h);
  }, []), D = c(
    async (l, s) => {
      let t = null, r = null;
      try {
        return n({ playerPortalConfigError: null, playerPortalConfigFetchStatus: a.FETCHING }), t = await u.fetchConfigs({
          sdk: o,
          appName: i.WIDGET,
          discoveryData: l,
          widgetOptions: s,
          useConfigService: !0
        }) || null, { data: t };
      } catch (e) {
        return r = p.getErrorType(e), { error: r };
      } finally {
        n({
          playerPortalConfigData: t,
          playerPortalConfigError: r,
          playerPortalConfigFetchStatus: a.IDLE
        });
      }
    },
    [o]
  ), C = c(
    async (l, s) => {
      let t = null, r = null;
      try {
        return n({ launcherData: null, launcherFetchStatus: a.FETCHING }), t = await u.fetchConfigs({
          sdk: o,
          appName: i.LAUNCHER,
          discoveryData: l,
          widgetOptions: s,
          useConfigService: !0
        }) || null, { data: t };
      } catch (e) {
        return r = p.getErrorType(e), { error: r };
      } finally {
        n({
          launcherData: t,
          launcherError: r,
          launcherFetchStatus: a.IDLE
        });
      }
    },
    [o]
  ), m = c(
    async (l, s) => {
      let t = null, r = null;
      try {
        return n({ paymentError: null, paymentFetchStatus: a.FETCHING }), t = await u.fetchConfigs({
          sdk: o,
          appName: i.PAYMENT,
          discoveryData: l,
          widgetOptions: s,
          useConfigService: !0
        }) || null, { data: t };
      } catch (e) {
        return r = p.getErrorType(e), { error: r };
      } finally {
        n({
          paymentData: t,
          paymentError: r,
          paymentFetchStatus: a.IDLE
        });
      }
    },
    [o]
  ), S = c(
    async (l, s) => {
      let t = null, r = null, e = null;
      try {
        return n({ twitchDropError: null, twitchDropFetchStatus: a.FETCHING }), t = await u.fetchConfigs({
          sdk: o,
          appName: i.TWITCHDROP,
          discoveryData: l,
          widgetOptions: s,
          useConfigService: !0
        }) || null, r = ((t == null ? void 0 : t.gameList.data.games) || []).map((f) => ({
          value: f.gameId,
          label: f.gameName,
          namespace: f.namespace,
          clientId: f.clientId
        })), { data: t };
      } catch (g) {
        return e = p.getErrorType(g), { error: e };
      } finally {
        n({
          twitchDropData: t,
          twitchDropGamesData: r,
          twitchDropError: e,
          twitchDropFetchStatus: a.IDLE
        });
      }
    },
    [o]
  ), F = c(
    async (l, s) => {
      let t = null, r = null;
      try {
        return n({ supportError: null, supportFetchStatus: a.FETCHING }), t = await u.fetchConfigs({
          sdk: o,
          appName: i.SUPPORT,
          discoveryData: l,
          widgetOptions: s,
          useConfigService: !0
        }) || null, { data: t };
      } catch (e) {
        return r = p.getErrorType(e), { error: r };
      } finally {
        n({
          supportData: t,
          supportError: r,
          supportFetchStatus: a.IDLE
        });
      }
    },
    [o]
  );
  return {
    state: E,
    mutations: {
      resetState: y,
      fetchPlayerPortalConfigs: D,
      fetchLauncherConfigs: C,
      fetchPaymentConfigs: m,
      fetchTwitchDropConfigs: S,
      fetchSupportConfigs: F
    }
  };
}
export {
  G as u
};
