/*! phoscon-app 2024-10-07 */

import{serviceSend}from"./settings-gateway-machine.js";import{states,events}from"./settings-gateway-constants.js";import{resetGw,unloadListener}from"./settings-gateway-functions.js";const GATEWAY_BACKUP_SUCCESS=2e4,GATEWAY_BACKUP_FAIL=6e3,LOGOUT_TIME=3e3;export var ResetViewHandlerFactory=view=>(ctx,activity)=>{let event=activity.type;if(event===states.RESET)view.show(),serviceSend(states.RESET_PAGE_1);else if(event===events.CLOSE_PRESSED){view.hide(),serviceSend(states.IDLE),document.querySelector(".context-menu-icon").parentNode.classList.remove("show-context")}};export var ResetViewPage1HandlerFactory=view=>(ctx,activity)=>{let event=activity.type;event===states.RESET_PAGE_1?(view.show(),view.page1()):event===events.NEXT_PRESSED&&serviceSend(states.RESET_PAGE_2)};export var ResetViewPage2HandlerFactory=view=>(ctx,activity)=>{let event=activity.type;event===states.RESET_PAGE_2?(window.addEventListener("beforeunload",unloadListener),resetGw(),view.page2()):event===events.RESET_SUCCESS?app.resetGatewayTimer=setTimeout(function(){serviceSend(states.RESET_PAGE_3)},2e4):event===events.RESET_FAIL&&(app.resetGatewayTimer=setTimeout(function(){serviceSend(states.RESET_PAGE_4)},6e3))};export var ResetViewPage3HandlerFactory=view=>(ctx,activity)=>{let event=activity.type;event===states.RESET_PAGE_3?(window.removeEventListener("beforeunload",unloadListener),view.page3()):event===events.LOGOUT_PRESSED&&logout()};export var ResetViewPage4HandlerFactory=view=>(ctx,activity)=>{activity.type===states.RESET_PAGE_4&&(window.removeEventListener("beforeunload",unloadListener),view.page4())};