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

import{serviceSend}from"./settings-gateway-machine.js";import{states,events}from"./settings-gateway-constants.js";import{resetHomebridge,unloadListener}from"./settings-gateway-functions.js";const RESET_HOMEBRIDGE_TO_SUCCESS=3e4,RESET_HOMEBRIDGE_TO_FAIL=1e4;export var ResetHomebridgeViewHandlerFactory=view=>(ctx,activity)=>{let event=activity.type;event===states.RESET_HOMEBRIDGE?(view.show(),serviceSend(states.RESET_HOMEBRIDGE_PAGE_1)):event===events.CLOSE_PRESSED&&(view.hide(),serviceSend(states.IDLE))};export var ResetHomebridgeViewPage1HandlerFactory=view=>(ctx,activity)=>{let event=activity.type;event===states.RESET_HOMEBRIDGE_PAGE_1?view.page1():event===events.NEXT_PRESSED&&serviceSend(states.RESET_HOMEBRIDGE_PAGE_2)};export var ResetHomebridgeViewPage2HandlerFactory=view=>(ctx,activity)=>{let event=activity.type;event===states.RESET_HOMEBRIDGE_PAGE_2?(window.addEventListener("beforeunload",unloadListener),resetHomebridge(),view.page2()):event===events.RESET_HOMEBRIDGE_SUCCESS?app.resetGatewayTimer=setTimeout(function(){serviceSend(states.RESET_HOMEBRIDGE_PAGE_3)},3e4):event===events.RESET_HOMEBRIDGE_FAIL&&(app.resetGatewayTimer=setTimeout(function(){serviceSend(states.RESET_HOMEBRIDGE_PAGE_4)},1e4))};export var ResetHomebridgeViewPage3HandlerFactory=view=>(ctx,activity)=>{activity.type===states.RESET_HOMEBRIDGE_PAGE_3&&(window.removeEventListener("beforeunload",unloadListener),view.page3())};export var ResetHomebridgeViewPage4HandlerFactory=view=>(ctx,activity)=>{activity.type===states.RESET_HOMEBRIDGE_PAGE_4&&(window.removeEventListener("beforeunload",unloadListener),view.page4())};