"use strict";const t=require("./FetchConfigsUtils-c73b687c.js"),c=require("react"),p={playerPortalConfigData:null,playerPortalConfigError:null,playerPortalConfigFetchStatus:t.FetchStatus.IDLE,launcherData:null,launcherError:null,launcherFetchStatus:t.FetchStatus.IDLE,paymentData:null,paymentError:null,paymentFetchStatus:t.FetchStatus.IDLE,twitchDropData:null,twitchDropGamesData:null,twitchDropError:null,twitchDropFetchStatus:t.FetchStatus.IDLE,supportData:null,supportError:null,supportFetchStatus:t.FetchStatus.IDLE},y=t.createStore(p);function D(){const[l]=t.useSdk(),[h,n]=t.useStore(y),g=c.useCallback(()=>{n(p)},[]),f=c.useCallback(async(o,s)=>{let e=null,r=null;try{return n({playerPortalConfigError:null,playerPortalConfigFetchStatus:t.FetchStatus.FETCHING}),e=await t.FetchConfigsUtils.fetchConfigs({sdk:l,appName:t.AppName.WIDGET,discoveryData:o,widgetOptions:s,useConfigService:!0})||null,{data:e}}catch(a){return r=t.WidgetErrorHelper.getErrorType(a),{error:r}}finally{n({playerPortalConfigData:e,playerPortalConfigError:r,playerPortalConfigFetchStatus:t.FetchStatus.IDLE})}},[l]),E=c.useCallback(async(o,s)=>{let e=null,r=null;try{return n({launcherData:null,launcherFetchStatus:t.FetchStatus.FETCHING}),e=await t.FetchConfigsUtils.fetchConfigs({sdk:l,appName:t.AppName.LAUNCHER,discoveryData:o,widgetOptions:s,useConfigService:!0})||null,{data:e}}catch(a){return r=t.WidgetErrorHelper.getErrorType(a),{error:r}}finally{n({launcherData:e,launcherError:r,launcherFetchStatus:t.FetchStatus.IDLE})}},[l]),C=c.useCallback(async(o,s)=>{let e=null,r=null;try{return n({paymentError:null,paymentFetchStatus:t.FetchStatus.FETCHING}),e=await t.FetchConfigsUtils.fetchConfigs({sdk:l,appName:t.AppName.PAYMENT,discoveryData:o,widgetOptions:s,useConfigService:!0})||null,{data:e}}catch(a){return r=t.WidgetErrorHelper.getErrorType(a),{error:r}}finally{n({paymentData:e,paymentError:r,paymentFetchStatus:t.FetchStatus.IDLE})}},[l]),S=c.useCallback(async(o,s)=>{let e=null,r=null,a=null;try{return n({twitchDropError:null,twitchDropFetchStatus:t.FetchStatus.FETCHING}),e=await t.FetchConfigsUtils.fetchConfigs({sdk:l,appName:t.AppName.TWITCHDROP,discoveryData:o,widgetOptions:s,useConfigService:!0})||null,r=((e==null?void 0:e.gameList.data.games)||[]).map(u=>({value:u.gameId,label:u.gameName,namespace:u.namespace,clientId:u.clientId})),{data:e}}catch(i){return a=t.WidgetErrorHelper.getErrorType(i),{error:a}}finally{n({twitchDropData:e,twitchDropGamesData:r,twitchDropError:a,twitchDropFetchStatus:t.FetchStatus.IDLE})}},[l]),F=c.useCallback(async(o,s)=>{let e=null,r=null;try{return n({supportError:null,supportFetchStatus:t.FetchStatus.FETCHING}),e=await t.FetchConfigsUtils.fetchConfigs({sdk:l,appName:t.AppName.SUPPORT,discoveryData:o,widgetOptions:s,useConfigService:!0})||null,{data:e}}catch(a){return r=t.WidgetErrorHelper.getErrorType(a),{error:r}}finally{n({supportData:e,supportError:r,supportFetchStatus:t.FetchStatus.IDLE})}},[l]);return{state:h,mutations:{resetState:g,fetchPlayerPortalConfigs:f,fetchLauncherConfigs:E,fetchPaymentConfigs:C,fetchTwitchDropConfigs:S,fetchSupportConfigs:F}}}exports.useAppConfigs=D;
