/*! phoscon-app 2025-10-13 */

export var overviewInit=(views,constants,ctx)=>params=>{let ov=views.overviewView;ov.setGroupName(app.session.gid),ov.setClass("navigation")};export var overviewSwInit=(views,constants,ctx)=>params=>{let swid=params.swid;swid&&(app.session.swid=swid,activeSw(swid,views),deActivateRl(views))};export var overviewRlInit=(views,constants,ctx)=>params=>{let swid=params.swid,rlid=params.rlid;rlid&&swid&&(app.session.rlid=rlid,activeRl(swid,rlid,views),views.mainSwView.listView.setSwitchActive(swid))};export var ovSwPressed=(views,constants,ctx)=>params=>{let swid=params.swid;swid&&app.router.navigate("overview/switch/"+swid,{trigger:!0})};export var ovRlPressed=(views,constants,ctx)=>params=>{let rlid=params.rlid;rlid&&app.router.navigate("overview/switch/"+app.session.swid+"/rl/"+rlid,{trigger:!0})};export var ovFuncPressed=(views,constants,ctx)=>params=>{let oid=params.oid,aid=params.aid;oid&&(app.session.oid=oid,views.mainSwView.showSaveDialog(),aid&&(app.session.addoid=aid))};export var ovDismissPressed=(views,constants,ctx)=>params=>{delete app.session.oid,delete app.session.addoid,views.mainSwView.hideSaveDialog(),location.reload()};export var ovSavePressed=(views,constants,ctx)=>params=>{let swid=params.swid;if(!swid)return;let sw,snid,cube,statekey,rl=app.resourcelinks.get(app.session.rlid);snid=(sw=app.switches.get(swid)).get("uniqueid"),statekey=(cube=!(!sw||-1===sw.get("modelid").indexOf("cube")))?"gesture":"buttonevent",constants.createResource(app.session.gid,snid,app.session.oid,app.session.eid,app.session.color,rl,constants,views.mainFuncView.listView,statekey,app.session.addoid).then(id=>{delete app.session.oid,delete app.session.addoid,app.session.rlid=id,app.router.navigate("overview/switch/"+app.session.swid+"/rl/"+id,{trigger:!0})}).catch(console.log),views.mainSwView.hideSaveDialog(),setTimeout(()=>{views.mainRlView.listView.showActiveSWResourcelinks(app.session.swid),views.mainRlView.listView.setRlActive(app.session.rlid)},100),loadLanguage()};export var ovDeleteSwRules=(views,constants,ctx)=>params=>{let rlviews=views.mainRlView.listView.views,toDelete=[];var sw=app.switches.get(app.session.swid);rlviews.forEach(v=>{if(v.el.getAttribute("data-swid")!=app.session.swid)return;let rlid=v.el.getAttribute("data-rlid"),rl=app.resourcelinks.get(rlid);rl&&toDelete.push(rl)});let hf=constants.helperFuncs;toDelete.forEach(rl=>{hf.deleteResource(rl,sw)})};function activeSw(swid,views){let overview=views.overviewView,swView=views.mainSwView,rlView=views.mainRlView;overview.setClass("resourcelinks"),swView.listView.setSwitchActive(swid),rlView.setActiveSwitch(swid),rlView.listView.showActiveSWResourcelinks(swid)}function activeRl(swid,rlid,views){let overview=views.overviewView,rlView=views.mainRlView,fuView=views.mainFuncView;overview.setClass("rlFunction"),rlView.setActiveSwitch(swid),rlView.listView.showActiveSWResourcelinks(swid),fuView.listView.showActiveRlFunction(rlid),fuView.setFuncListHead(rlid),fuView.enableDeleteBtn(rlid),screenMax(SCREEN_MAX_WIDTH_PHONE_PORTRAIT)||screen.height<420||rlView.listView.setRlActive(rlid)}function deActivateRl(views){let fuView=views.mainFuncView;fuView.listView.hideActiveRlFunction(),fuView.setFuncListHead(),fuView.enableDeleteBtn()}