/*! phoscon-app 2024-02-26 */

import{ButtonEvents,StateEvents,WifiEvents,GeneralStates,UiStates,Types,ApiStates}from"./state-constants.js";import{appSetState,initClientModeState,stateHandlerMap}from"./state-handler.js";export var clientHandlerFactory=(view,setState,wifi)=>event=>{if(event===StateEvents.ENTER_STATE)view.showClientMode(),initClientModeState();else if(event!==StateEvents.LEAVE_STATE)return StateEvents.NOT_HANDLED};export var clientOverwriteApHandlerFactory=(view,setState,wifi)=>event=>{if(event===StateEvents.ENTER_STATE)view.show();else if(event===StateEvents.LEAVE_STATE)view.hide();else if(event===ButtonEvents.OVERWRITE_AP_PRESSED)appSetState(UiStates.CLIENT_CONFIGURED_OR_NOT_CONFIGURED);else if(event===WifiEvents.CONFIG_CHANGED)setState(UiStates.CLIENT);else{if(event!==ButtonEvents.TAB_AP_PRESSED)return StateEvents.NOT_HANDLED;appSetState(UiStates.AP)}};export var clientConfiguredNonAppFactory=(view,setState,wifi)=>event=>{if(event===StateEvents.ENTER_STATE)view.show();else if(event===StateEvents.LEAVE_STATE)view.hide();else if(event===WifiEvents.CONFIG_CHANGED)setState(UiStates.CLIENT);else if(event===ButtonEvents.TAB_AP_PRESSED)setState(UiStates.AP);else{if(event!==ButtonEvents.CONFIGURE_CLIENT_PRESSED)return StateEvents.NOT_HANDLED;setState(UiStates.CLIENT_CONFIGURED_OR_NOT_CONFIGURED)}};export const clientConfiguredOrNotConfiguredHandlerFactory=(setState,wifi)=>event=>{if(event===StateEvents.ENTER_STATE)wifi.get("workingtype")===Types.CLIENT&&wifi.get("wifi")!==ApiStates.DEACTIVATED?setState(UiStates.CLIENT_CONFIGURED):setState(UiStates.CLIENT_NOT_CONFIGURED);else if(event!==StateEvents.LEAVE_STATE)return StateEvents.NOT_HANDLED};