import{a as _,c as K,d as c}from"./chunk-7TSMJPAD.js";import{B as N}from"./chunk-XYDYISIG.js";import{Da as y,Ea as b,Fa as M,Fc as T,Ga as P,Gc as C,Kf as A,Kg as H,L as s,Lc as x,Lf as E,Nc as w,Qf as U,Rb as S,Tf as L,Wa as v,Xg as D,a as u,da as p,ef as O,gb as k,kg as a,oa as d,pe as I,qg as R,v as g,xa as m,ya as f}from"./chunk-VZVHAHX6.js";import{i as h}from"./chunk-UDPOFCFO.js";var F=[{home:!0,icon:{icon:"home",pack:"CombainIcons"},link:"/pages/home",title:"Home"},{icon:"mobile-alt",link:"/pages/devices",title:"Devices",userPolicy:41,pathMatch:"prefix"},{icon:"users",link:"/pages/settings/users",title:"Users",userPolicy:36},{icon:"bell",link:"/pages/alerts",title:"Alerts",userPolicy:3,pathMatch:"prefix"},{icon:"map-marker-alt",link:"/pages/places",title:"Places",userPolicy:52,pathMatch:"prefix"},{icon:"cog",title:"Settings",children:[{link:"/pages/settings/profileedit",title:"- Profile",userPolicy:33},{link:"/pages/settings/accountedit",title:"- Account",userPolicy:7},{link:"/pages/settings/mapoptionedit",title:"- Map Options",userPolicy:115},{link:"/pages/settings/kioskoptions",title:"- Kiosk Mode Options",userPolicy:115},{link:"/pages/settings/usertracking",title:"- Tracking",userPolicy:115},{link:"/pages/settings/attributes",title:"- Attributes",userPolicy:72},{link:"/pages/settings/alertrules",title:"- Alert Rules",userPolicy:20,pathMatch:"prefix"},{link:"/pages/settings/alert-types",title:"- Alert Types",userPolicy:1008,pathMatch:"prefix"},{link:"/pages/settings/integrations",title:"- Integrations",userPolicy:86,pathMatch:"prefix"},{link:"/pages/settings/account-templates",title:"- Account Templates",userPolicy:1018,pathMatch:"prefix"},{link:"/pages/settings/email-templates",title:"- Email Templates",userPolicy:98,pathMatch:"prefix"},{link:"/pages/settings/sms-templates",title:"- SMS Templates",userPolicy:93,pathMatch:"prefix"},{link:"/pages/settings/subscriptions",title:"- subscriptions",userPolicy:108,pathMatch:"prefix"}]},{icon:"history",title:"Logs",userPolicy:34,children:[{link:"/pages/logs",title:"- Api",pathMatch:"prefix"},{link:"/pages/integrationlogs/emaillist",title:"- Emails",pathMatch:"prefix"},{link:"/pages/integrationlogs/smslist",title:"- SMS",pathMatch:"prefix"},{link:"/pages/integrationlogs/httplist",title:"- Http",pathMatch:"prefix"}]}];function B(i,t){if(i&1&&(b(0,"tm-layout"),P(1,"nb-menu",1)(2,"router-outlet"),M()),i&2){let e=v();k("noMenu",!e.PagesComponent.menu.length),p(),y("items",e.PagesComponent.menu)}}var j=class i{static{this.menu=[]}static{this.defaultMenu=Promise.resolve(F)}static{this.serviceTypeId=6}static{this.customerReady=!1}static{this.homePath="/pages/home"}static{this.subscribed=!1}constructor(){this.globalState=s(R),this.dialogService=s(O),this.tmDeviceService=s(H),this.translate=s(C),this.translateParser=s(T),this.cvService=s(U),this.api=s(A),this.idle=s(_),this.cd=s(S),this.router=s(w),this.config=s("config"),this.PagesComponent=i,this.displayLanguage="",this.subscriptions=new u,this.isHandlingTranslation=!1}ngOnInit(){if(i.subscribed)return;i.subscribed=!0,this.globalState.customer||this.globalState.feedMe(),this.globalState.customerReady.subscribe(()=>{this.translateMenu(),this.logoutTimer()});let t;E.invalidTokenEvent.subscribe(()=>{console.log("event http service invalid token"),this.autoLogoutUser()})}missingTranslationHandler(t){if(t.key==="load")return;if(this.isHandlingTranslation)return this.translateParser.interpolate(t.key,t.interpolateParams);let e=t.translateService;if(t.key[0]==="~")return this.translateParser.interpolate(t.key.substr(1),t.interpolateParams);this.isHandlingTranslation=!0;try{if(e.instant("load")==="load")return this.isHandlingTranslation=!1,this.translateParser.interpolate(t.key,t.interpolateParams);e.get("load").subscribe(()=>{try{e.instant(t.key)===t.key&&(this.config.addTranslations&&t.key?.trim()&&this.api.postPath("translate",{key:t.key,path:location.hash}).subscribe(),console.warn("Missing translation!",t,new Error().stack),e.setTranslation(e.defaultLang||"en",{[t.key]:null},!0))}finally{this.isHandlingTranslation=!1}})}catch{this.isHandlingTranslation=!1}return this.translateParser.interpolate(t.key,t.interpolateParams)}menuItemAllowed(t){return t.title==="- Kiosk Options"&&this.globalState.customer?.json?.kioskMode===0||this.cvService.viewing()&&t.title==="- Profile"?!1:this.globalState.isUserAllowed(t.userPolicy)&&this.globalState.isCustomerAllowed(t.customerPolicy)}filterMenu(t){return t.filter(e=>this.menuItemAllowed(e)?e.children?(e.children=this.filterMenu(e.children),e.children.length>0):!0:!1)}translateMenu(){return h(this,null,function*(){if(this.translate.missingTranslationHandler={handle:this.missingTranslationHandler.bind(this)},this.displayLanguage===this.globalState.user?.json?.displayLanguage&&this.displayLanguage!=="")return;if(this.displayLanguage=this.globalState.user?.json?.displayLanguage||"en",i.customerReady=!0,this.globalState.isUserAllowed(a.KioskAutoRedirect)&&this.router.url!==c&&this.router.navigate([c]),this.globalState.isUserAllowed(a.HideSideMenu)){i.menu=[];return}let t=D.deepCopy(yield i.defaultMenu),e=JSON.parse(JSON.stringify(this.globalState.customer?.services?.find(o=>o.serviceTypeId===i.serviceTypeId)||{})),n=e?.sideMenu?.remove||[],l=t.filter(o=>!n.includes(o.title));e?.sideMenu?.add&&l.push(...e.sideMenu.add),i.menu=this.filterMenu(l),yield this.translate.get("load").toPromise();for(let o of i.menu)if(o.title&&(o.title=this.translate.instant(o.title)),o.children)for(let r of o.children)r.title&&(r.title=this.translate.instant(r.title))})}logoutTimer(){this.config.logoutTime&&(this.globalState.isUserAllowed(a.KioskAutoRedirect)||(this.idle.setIdle(this.config.logoutTime),this.idle.setTimeout(this.config.logoutTime),this.idle.setInterrupts(K),this.idle.watch(),this.idle.onIdleStart.subscribe(()=>{this.idleState="IDLE"}),this.idle.onIdleEnd.subscribe(()=>{this.idleState="NOT_IDLE",this.cd.detectChanges()}),this.idle.onTimeout.subscribe(()=>{this.idleState="TIMED_OUT",this.autoLogoutUser()})))}autoLogoutUser(){let t=document.getElementsByTagName("nb-spinner");for(let n=0;n