(()=>{var Oe=Object.defineProperty,Ce=Object.defineProperties;var ke=Object.getOwnPropertyDescriptors;var te=Object.getOwnPropertySymbols;var Ie=Object.prototype.hasOwnProperty,Ne=Object.prototype.propertyIsEnumerable;var ae=(a,e,t)=>e in a?Oe(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,b=(a,e)=>{for(var t in e||(e={}))Ie.call(e,t)&&ae(a,t,e[t]);if(te)for(var t of te(e))Ne.call(e,t)&&ae(a,t,e[t]);return a},ne=(a,e)=>Ce(a,ke(e));var se=(a,e,t)=>new Promise((n,s)=>{var i=o=>{try{r(t.next(o))}catch(l){s(l)}},c=o=>{try{r(t.throw(o))}catch(l){s(l)}},r=o=>o.done?n(o.value):Promise.resolve(o.value).then(i,c);r((t=t.apply(a,e)).next())});var h,T,D;function Re(){h.dataset.navState="displayed",h.classList.remove("state-off"),h.classList.add("state-on"),T.classList.add("a-show")}function F(){h.dataset.navState="hidden",h.classList.remove("state-on"),h.classList.add("state-off"),T.classList.add("a-hide"),T.classList.remove("a-show"),setTimeout(()=>{T.classList.remove("a-hide")},300)}function ie(){console.log("HUD init"),h=document.querySelector(".hud .nav-toggle"),T=document.querySelector(".hud .navigation"),D=document.querySelector(".hud .reload-screen"),h==null||h.addEventListener("click",a=>{a.currentTarget.dataset.navState!="displayed"?Re():F()}),D==null||D.addEventListener("click",a=>{Screens.reload()})}var M=class{constructor(e,t,n){this.screens={},this.routesMap={},this.currentScreen=null,this.eventsHandlers={switch:[],reload:[],reinit:[],errorScreen:[]},this.screensContainer=document.querySelector(e),this.loader=document.querySelector(t),this.errorScreen=document.querySelector(n),console.log("Screens Init")}add(e,t){if(typeof t!="object")return console.error("Screens: screens must be object");if(typeof(t==null?void 0:t.alias)=="undefined")return console.error("Screens: undefined alias");if(typeof(t==null?void 0:t.renderer)!="function")return console.error("Screens: renderer must be function");this.screens[t.alias]=b({route:e},t),this.routesMap[e]=t.alias}switch(e){var n;if(this.runSwitchHandlers(e),this.hideErrorScreen(),this.showLoader(),(n=this.currentScreen)==null||n.DOMObject.remove(),typeof this.screens[e]=="undefined"){console.error(`Screens: "${e}" not found`);return}this.currentScreen=this.screens[e];let t=document.createElement("div");t.classList.add("screen"),t.id=e,t.dataset.alias=e,t.innerHTML=this.currentScreen.renderer(),this.currentScreen.DOMObject=t,this.screensContainer.append(this.currentScreen.DOMObject),this.currentScreen.initer(this)}reload(){this.currentScreen&&(this.runReloadHandlers(this.currentScreen.alias),this.switch(this.currentScreen.alias))}reinit(){this.currentScreen&&(this.currentScreen.initer(this),this.runReinitHandlers())}routing(){setInterval(()=>{let e=document.location.hash.split("#!")[1];if(typeof e=="undefined"||e=="")return;let t=typeof this.routesMap[e]=="undefined"?"not-found-screen":this.routesMap[e];(!this.currentScreen||this.currentScreen.alias!=t)&&this.switch(t)},50)}ready(){this.currentScreen!=null&&(this.currentScreen.DOMObject||(this.currentScreen.DOMObject=document.getElementsById(this.currentScreen.alias)),this.hideLoader(),this.currentScreen.DOMObject.classList.add("a-show"))}error(e,t){var n;(n=this.currentScreen)==null||n.DOMObject.remove(),this.errorScreen.querySelector(".error-title").innerHTML=e,this.errorScreen.querySelector(".error-text").innerHTML=t,this.showErrorScreen(),this.runErrorScreenHandlers()}hideLoader(){this.loader.classList.remove("a-show")}showLoader(){this.loader.classList.add("a-show")}showErrorScreen(){this.errorScreen.classList.add("a-show")}hideErrorScreen(){this.errorScreen.classList.remove("a-show")}getScreens(){return this.screens}getRoutesMap(){return this.routesMap}onSwitch(e){this.eventsHandlers.switch.push(e)}onReaload(e){this.eventsHandlers.reload.push(e)}onReinit(e){this.eventsHandlers.reinit.push(e)}onErrorScreen(e){this.eventsHandlers.errorScreen.push(e)}runSwitchHandlers(e){let t=Object.keys(this.routesMap).filter(n=>this.routesMap[n]==e);for(let n of this.eventsHandlers.switch)n(this,e,t.length?t[0]:void 0)}runReloadHandlers(e){for(let t of this.eventsHandlers.reload)t(this,e)}runReinitHandlers(){for(let e of this.eventsHandlers.reinit)e(this)}runErrorScreenHandlers(){for(let e of this.eventsHandlers.errorScreen)e(this)}};function xe(a,e,t,n){return`
		<div class="toast toast-${a}" role="alert">
	    <div class="toast-content">
	      <h4 class="toast-title">${e} ${t}</h4>
	      <p class="toast-text">${n}</p>
	    </div>
	    <button class="btn-icon toast-close" type="button" aria-label="Close">\u2715</button>
	  </div>
	`}function je(a,e){if(e!=null&&e.alone&&document.querySelectorAll(".toast").forEach(t=>t.close()),a.close=function(){this.classList.add("a-hide"),setTimeout(()=>{this.remove()},300)},a.querySelector(".toast-close").addEventListener("click",t=>{a.close()}),a.show=function(){document.querySelector("body").append(a),setTimeout(()=>{a.classList.add("a-show")},10)},typeof Screens!="undefined"&&Screens.onSwitch((t,n)=>{setTimeout(()=>{a==null||a.close()},1e4)}),a.addEventListener("mouseover",t=>a.ishovered=!0),a.addEventListener("mouseout",t=>a.ishovered=!1),e!=null&&e.lifetime){console.log(e);let t=setInterval(()=>{a.ishovered||(a.close(),clearInterval(t))},e==null?void 0:e.lifetime)}return a}function H(a,e,t,n,s){let i=document.createElement("div");return i.innerHTML=xe(a,e,t,n),je(i.childNodes[1],s)}function Fe(a,e,t){return typeof t=="undefined"&&(t={}),typeof t.lifetime=="undefined"&&(t.lifetime=4e3),typeof t.alone=="undefined"&&(t.alone=!0),H("success",'<i class="ph ph-check-circle"></i>',a,e,t)}function Pe(a,e,t){return H("info",'<i class="ph ph-info"></i>',a,e,t)}function Ue(a,e,t){return H("warning",'<i class="ph ph-warning"></i>',a,e,t)}function re(a,e,t){return H("danger",'<i class="ph ph-warning-octagon"></i>',a,e,t)}var oe={create:H,createInfo:Pe,createSuccess:Fe,createWarning:Ue,createError:re,createDanger:re};function Be(a){let e="";for(let t of a){let n="",s="";t.route&&(n=`<a class="list-action" href="${t.route}">`,s="</a>"),e+=`
			<li class="list-item ${t.is_active?"list-item-active":""}">
				${n}${t.content}${s}
			</li>
		`}return`
		<div class="sidebar block">
			<ul class="list list-nav">
				${e} 
			</ul>
		</div>
	`}function ze(a,e,t,n){let s='<tr class="table-row">',i=0;for(let u in e)s+=`<th scope="col">${e[u]}</th>`,i++;s+="</tr>";let c="";for(let u of t){c+='<tr class="table-row">';for(let m in e)c+=`<td>${u[m]}</td>`;c+="</tr>"}let r="";typeof n!="undefined"&&(r=`
			<tfoot class="table-foot">
				<tr class="table-row">
					<td colspan="${i}">
						${n}
					</td>
				</tr>
			</tfoot>
		`);let o=a?`<caption class="table-caption">${a}</caption>`:"",l=t.length?`<thead class="table-head">${s}</thead>`:"";return c=t.length?c:'<tr><td class="is-empty">Empty</td></tr>',`
		<div class="table-wrapper">
			<table class="table devices-lists ${t.length?"":"table-empty"}">
				${o}
				${l}
				<tbody class="table-body">${c}</tbody>
				${r}
			</table>
		</div>
	`}function ce(a,e,t){let n=document.createElement(a);for(let[s,i]of Object.entries(e))s==="class"?n.className=i:s==="dataset"?Object.assign(n.dataset,i):n.setAttribute(s,i);return n.innerHTML=typeof t!="undefined"?t:"",n}function Ve(a,e){return["primary","success","secondary","info","warning","error","danger"].indexOf(a)<0?console.error("createAlert()","Error of type: "+a):ce("div",{class:`alert alert-${a}`},e)}function Je(a){let e={device_name:"name",device_hard_id:"device_id",device_ip:"ip",device_type:"type",ip_address:"ip",mac_address:"mac",device_mac:"mac",core_version:"firmware_core_version"},t={};for(let n in a){if(typeof e[n]!="undefined"){t[e[n]]=a[n];continue}t[n]=a[n]}return t}function We(a,e){if((a==null?void 0:a.isLoading)==e)return!1;if(e)a.isLoading=!0,a.originalContent=a.innerHTML,a.classList.contains("with-icon")?a.originalWithIcon=!0:a.classList.add("with-icon"),a.classList.add("loading-state"),a.setAttribute("disabled","disabled"),a.innerHTML='<i class="ph-bold ph-spinner"></i> Loading';else{if(a.isLoading=!1,!a.originalContent)return!1;a.removeAttribute("disabled"),a.classList.remove("loading-state"),a.originalWithIcon||a.classList.remove("with-icon"),a.innerHTML=a.originalContent}return a}function Ye(a,e){if((a==null?void 0:a.isLoading)==e)return!1;let t=a.querySelector(".device-icon");if(e)a.isLoading=!0,a.originalContent=t.innerHTML,a.classList.add("loading-state"),a.setAttribute("disabled","disabled"),t.innerHTML='<i class="ph-bold ph-spinner"></i>';else{if(a.isLoading=!1,!a.originalContent)return!1;a.removeAttribute("disabled"),a.classList.remove("loading-state"),t.innerHTML=a.originalContent}return a}function Ge(a,e){return e=e!=null?e:"",`
		<div class="container">
			<div class="row adaptive g-6">
				<div class="col sidebar-container">
					${a}
				</div>
				<div class="col main-container w-100">
					${e}
				</div>
			</div>
		</div>
	`}function Ke(a){return a=="active"?'<span class="badge badge-success">Online</span>':'<span class="badge badge-warning">Offline</span>'}function Qe(a){return a=="enabled"?'<span class="badge badge-success">Enabled</span>':'<span class="badge badge-primary">Disabled</span>'}function Xe(a){let e=new Date(a.replace(" ","T")),n=Math.floor((new Date-e)/1e3);if(n<60)return"less than a minute ago";let s=Math.floor(n/60),i=Math.floor(s/60),c=Math.floor(i/24);if(s<60)return`${s} minute${s!==1?"s":""} ago`;if(i<24){let r=s%60;return`${i} hour${i!==1?"s":""} ${r} minute${r!==1?"s":""} ago`}return`${c} day${c!==1?"s":""} ago`}function Ze(a){let e=new Date(a.replace(" ","T")),t=new Date,n=new Date(t.getFullYear(),t.getMonth(),t.getDate()),s=new Date(e.getFullYear(),e.getMonth(),e.getDate()),i=Math.floor((n-s)/864e5),c=String(e.getHours()).padStart(2,"0"),r=String(e.getMinutes()).padStart(2,"0");if(i===0)return`Today at ${c}:${r}`;if(i===1)return`Yesterday at ${c}:${r}`;let o=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];return`${e.getDate()} ${o[e.getMonth()]} ${e.getFullYear()} at ${c}:${r}`}function et(){return`
		<div class="circle-loader">
			<i class="ph-bold ph-spinner normalize"></i>
			Loading
		</div>
	`}function tt(){return`
		<div class="empty-here">
			<div class="icon"><i class="ph ph-placeholder normalize"></i></div>
			<p class="text-msg">It's empty here yet</p>
		</div>
	`}var le={template:{sidebarNav:Be,table:ze,createElement:ce,createAlert:Ve,mainTemplate:Ge,connectionStatusBadge:Ke,toogleStateBadge:Qe,circleLoaderHTML:et,emptyHereHTML:tt},unification:{deviceFieldsUnification:Je,timeAgo:Xe,formatDate:Ze},states:{btnLoadingState:We,cardScriptActionLoadingState:Ye}};var q=class{constructor(e){this.core=e}actions_list(e){return this.core.api_get("/api/v1/scripts/actions/list",e)}scopes_list(e){return this.core.api_get("/api/v1/scripts/scopes/list",e)}regular_list(e){return this.core.api_get("/api/v1/scripts/regular/list",e)}scope_get_by_filename(e,t){let n=encodeURIComponent(String(e||""));return this.core.api_get(`/api/v1/scripts/scopes/name/${n}`,t,{})}scope_create(e,t){return this.core.api_post("/api/v1/scripts/scopes/new",e,t)}scope_update(e,t){return this.core.api_post("/api/v1/scripts/scopes/update",e,t)}action_enable(e,t){let n=encodeURIComponent(String(e||""));return this.core.api_get(`/api/v1/scripts/actions/alias/${n}/enable`,t)}action_disable(e,t){let n=encodeURIComponent(String(e||""));return this.core.api_get(`/api/v1/scripts/actions/alias/${n}/disable`,t)}regular_enable(e,t){let n=encodeURIComponent(String(e||""));return this.core.api_get(`/api/v1/scripts/regular/alias/${n}/enable`,t)}regular_disable(e,t){let n=encodeURIComponent(String(e||""));return this.core.api_get(`/api/v1/scripts/regular/alias/${n}/disable`,t)}scope_enable(e,t){let n=encodeURIComponent(String(e||""));return this.core.api_get(`/api/v1/scripts/scopes/name/${n}/enable`,t)}scope_disable(e,t){let n=encodeURIComponent(String(e||""));return this.core.api_get(`/api/v1/scripts/scopes/name/${n}/disable`,t)}scope_remove(e,t){let n=encodeURIComponent(String(e||""));return this.core.api_get(`/api/v1/scripts/scopes/name/${n}/remove`,t)}run(e,t){return this.core.api_post("/api/v1/scripts/actions/run",e,t)}place_in_area(e,t){return this.core.api_post("/api/v1/scripts/place-in-area",e,t)}unassign_from_area(e,t){let n=encodeURIComponent(String(e));return this.core.api_get(`/api/v1/scripts/id/${n}/unassign-from-area`,t)}};var O=class{constructor(e){this.core=e}list(e){return this.core.api_get("/api/v1/devices/list",e)}scanning_setup(e){return this.core.api_get("/api/v1/devices/scanning/setup",e)}scanning_all(e){return this.core.api_get("/api/v1/devices/scanning/all",e)}setup_new_device(e,t){return this.core.api_post("/api/v1/devices/setup/new-device",e,t)}info(e,t){let n=encodeURIComponent(String(e));return this.core.api_get(`/api/v1/devices/id/${n}/info`,t)}get(e,t){let n=encodeURIComponent(String(e));return this.core.api_get(`/api/v1/devices/id/${n}`,t)}status(e,t){let n=encodeURIComponent(String(e));return this.core.api_get(`/api/v1/devices/id/${n}/status`,t)}action(e,t){return this.core.api_post("/api/v1/devices/action",e,t)}remove(e,t){let n=encodeURIComponent(String(e));return this.core.api_get(`/api/v1/devices/id/${n}/remove`,t)}reboot(e,t){let n=encodeURIComponent(String(e));return this.core.api_get(`/api/v1/devices/id/${n}/reboot`,t)}place_in_area(e,t){return this.core.api_post("/api/v1/devices/place-in-area",e,t)}unassign_from_area(e,t){let n=encodeURIComponent(String(e));return this.core.api_get(`/api/v1/devices/id/${n}/unassign-from-area`,t)}update_name(e,t){return this.core.api_post("/api/v1/devices/update-name",e,t)}update_description(e,t){return this.core.api_post("/api/v1/devices/update-description",e,t)}update_alias(e,t){return this.core.api_post("/api/v1/devices/update-alias",e,t)}};var C=class{constructor(e){this.core=e}list(e){return this.core.api_get("/api/v1/areas/list",e)}inner_list(e,t){let n=encodeURIComponent(String(e));return this.core.api_get(`/api/v1/areas/id/${n}/list`,t)}new_area(e,t){return this.core.api_post("/api/v1/areas/new-area",e,t)}remove(e,t){let n=encodeURIComponent(String(e));return this.core.api_get(`/api/v1/areas/id/${n}/remove`,t)}place_in_area(e,t){return this.core.api_post("/api/v1/areas/place-in-area",e,t)}update_display_name(e,t){return this.core.api_post("/api/v1/areas/update-display-name",e,t)}update_alias(e,t){return this.core.api_post("/api/v1/areas/update-alias",e,t)}devices(e,t){let n=encodeURIComponent(String(e));return this.core.api_get(`/api/v1/areas/id/${n}/devices`,t)}scripts(e,t){let n=encodeURIComponent(String(e));return this.core.api_get(`/api/v1/areas/id/${n}/scripts`,t)}unassign_from_area(e,t){let n=encodeURIComponent(String(e));return this.core.api_get(`/api/v1/areas/id/${n}/unassign-from-area`,t)}types_list(e){return this.core.api_get("/api/v1/areas/types/list",e)}reboot_devices(e,t){if(e==null)return this.core.api_get("/api/v1/areas/reboot_devices",t);let n=encodeURIComponent(String(e));return this.core.api_get(`/api/v1/areas/id/${n}/reboot_devices`,t)}};function de(a){if(!a||typeof a!="object")return"";let e=new URLSearchParams;Object.entries(a).forEach(([n,s])=>{s!=null&&e.append(n,String(s))});let t=e.toString();return t?`?${t}`:""}function at(a,e){let t=String(a||"").replace(/\/+$/,""),n=String(e||"").replace(/^\/+/,"");return`${t}/${n}`}function nt(a){try{return{ok:!0,data:JSON.parse(a)}}catch(e){return{ok:!1,error:e}}}var k=class{constructor(e){this.base_url=(e==null?void 0:e.base_url)||"",this.token=(e==null?void 0:e.token)||"",this.timeout_ms=Number.isFinite(e==null?void 0:e.timeout_ms)?e.timeout_ms:15e3,this.default_headers=(e==null?void 0:e.default_headers)||{},this.on_unauthorized=typeof(e==null?void 0:e.on_unauthorized)=="function"?e.on_unauthorized:null,this.proxy_path=(e==null?void 0:e.proxy_path)||"",this.scripts=new q(this),this.devices=new O(this),this.areas=new C(this)}set_base_url(e){this.base_url=e||""}set_token(e){this.token=e||""}set_proxy_path(e){this.proxy_path=e||""}_wrap_path(e,t){if(!this.proxy_path)return t?`${e}${de(t)}`:e;let n=b({path:e},t||{});return`${this.proxy_path}${de(n)}`}request(e,t,n,s,i){let c=typeof s=="function"?s:()=>{},r=at(this.base_url,t),o=new AbortController,l=Number.isFinite(i==null?void 0:i.timeout_ms)?i.timeout_ms:this.timeout_ms,d=setTimeout(()=>o.abort(),l),u=b(b({},this.default_headers),(i==null?void 0:i.headers)||{});this.token&&(u.Authorization=`Bearer ${this.token}`);let m;n!=null&&(u["Content-Type"]="application/json",m=JSON.stringify(n)),fetch(r,{method:e,headers:u,body:m,signal:o.signal}).then(p=>se(this,null,function*(){clearTimeout(d);let g={url:r,method:e,status_code:p.status,headers:p.headers},v=yield p.text(),j=nt(v),S=j.ok?j.data:v;if(!p.ok){let $={type:"http_error",message:`HTTP ${p.status}`,status_code:p.status,raw:S};if((p.status===401||p.status===403)&&this.on_unauthorized)try{this.on_unauthorized({error:$,meta:g})}catch(ee){}return c($,null,g)}if(j.ok&&S&&typeof S=="object"){let $=S.status;if($===!1||$==="error"){let ee={type:"api_error",message:S.message||"API error",status_code:p.status,raw:S,field:S.field};return c(ee,null,g)}}return c(null,S,g)})).catch(p=>{clearTimeout(d);let v=p&&(p.name==="AbortError"||String(p).includes("AbortError"))?{type:"timeout",message:`Timeout after ${l}ms`}:{type:"network_error",message:(p==null?void 0:p.message)||"Network error",details:p};return c(v,null,{url:r,method:e,status_code:0,headers:null})})}get(e,t,n){return this.request("GET",e,null,t,n)}post(e,t,n,s){return this.request("POST",e,t,n,s)}api_get(e,t,n,s){return this.get(this._wrap_path(e,n),t,s)}api_post(e,t,n,s,i){return this.post(this._wrap_path(e,s),t,n,i)}};function I(a){return Helper.template.sidebarNav([{content:'<span class="list-label"><i class="ph ph-cpu"></i> Devices</span>',route:"/#!/devices",is_active:a=="devices"},{content:'<span class="list-label"><i class="ph ph-magnifying-glass"></i> Scanning</span>',route:"/#!/devices/scanning",is_active:a=="scanning"}])}function _(a,e,t){Helper.states.btnLoadingState(e,!0);let n=e.dataset.deviceId,s=e.dataset.deviceName,i=e.dataset.deviceAlias;a.devices.reboot(n,(c,r,o)=>{Helper.states.btnLoadingState(e,!1),console.log("Reboot done",c,r,o),t==null||t.close(),r?(setTimeout(()=>Screens.reinit(),8e3),Toasts.createSuccess("Reboot successful",`Device: ${s}<br>
					Alias: <b>${i}</b>`).show()):Toasts.createError("Reboot failed",`Device: ${s}<br>
					Alias: <b>${i}</b>`).show()})}var f,P,ue,w,N,A,U={area:"areas",device:"devices",action:"scripts"};function B(){let a=f.querySelector(".current-area");for(let e of ue)if(e.id==w)return a.innerHTML=`${e.display_name}`;a.innerHTML=`Area ID ${w}`,ot()}function st(a){N[U[A]].unassign_from_area(a,(e,t,n)=>{if(console.log(`sh_api[${U[A]}].unassign_from_area`,e,t,n),!t||t.data.status)return Toasts.createError("Error of unassigning",t?t.data.error_alias:"Error of request").show();w=0,B(),z(),Toasts.createSuccess("Successfully unassigning","Successfully unassigning").show(),Screens.reinit()})}function it(a,e){a[U[A]].place_in_area(e,(t,n,s)=>{if(console.log("sh_api.areas.place_in_area",t,n,s),!n||!n.status)return console.error("Component placeInArea",t,n,s);let i=f.querySelector(".current-area");Toasts.createSuccess("Successfully applied","Successfully applied").show(),w=e.place_in_area_id,B(),z(),Screens.reinit(),console.log("Success",n)})}function rt(a,e){N.areas.list((t,n,s)=>{if(console.log("sh_api.areas.list",t,n,s),!n)return console.error("sh_api.areas.list",t);ue=n.data.areas,B();let i={};for(let r of n.data.areas)A=="area"&&r.id==a||(i[r.id]=r.display_name);let c=advancedSelect(f.querySelector(".select-area"),i,"Nothing found");f.querySelector(".advanced-select-container").append(c),c.advancedSelect.addEventListener("changed",r=>{e(r,n.data.areas)}),P.innerHTML="",P.append(f)})}function z(){let a=f.querySelector(".form-container");a.classList.remove("a-show"),a.classList.add("a-hide"),setTimeout(()=>a.classList.remove("a-hide"),300)}function ot(){let a=f.querySelector(".remove-parent-id");w==0?a.classList.add("d-none"):a.classList.remove("d-none")}function L(a,e,t,n,s){N=a,P=e,w=s,A=t,f=document.createElement("div"),f.classList.add("component"),f.classList.add("place-in-area-component"),f.innerHTML=`
		<span class="current-area"></span>
		<button class="btn-icon without-hover remove-parent-id"><i class="ph ph-backspace"></i></button>
		<button class="btn btn-primary with-icon show-place-in-area">
			<i class="ph ph-map-pin-line"></i>
			Place In Area
		</button>
		<div class="block form-group form-container">
			<button class="btn-icon hide-place-in-area">
				<i class="ph ph-x"></i>
			</button>
			<label class="label">
				Select Area
				<i class="ph ph-magnifying-glass"></i>
				<input type="text" class="input select-area" placeholder="Search">
			</label>
			<div class="advanced-select-container"></div>
		</div>
	`,rt(n,(c,r)=>{let o=c.advancedSelect.value();if(!o.isOption)return;let l=Object.keys(o.option)[0];it(N,{target_id:n,place_in_area_id:l})});let i=f.querySelector(".form-container");f.querySelector("button.show-place-in-area").addEventListener("click",c=>{i.classList.contains("a-show")?(i.classList.remove("a-show"),i.classList.add("a-hide"),setTimeout(()=>i.classList.remove("a-hide"),300)):i.classList.add("a-show")}),f.querySelector("button.hide-place-in-area").addEventListener("click",c=>{z()}),f.querySelector("button.remove-parent-id").addEventListener("click",c=>{st(n)})}var pe={relay:(a,e)=>{let t="";for(let n of e.channels){let s=n.state=="off"?"OFF":"ON",i=n.state=="on"?"badge-success":"",c=e.channels.length>1?`${n.id}:`:"";t+=`
				<span class="badge ${i}">${c}<b>${s}</b></span>
			`}return`<div class="channels f-grid g-2">${t}</div>`},button:(a,e)=>{let t={enabled:"badge-success",disabled:"",mute:"badge-primary-outline",waiting:"badge-warning",error:"badge-error"},n="";for(let s of e.channels)n+=`
				<span class="badge ${t[s.indicator]}">${s.id}:<b>${s.indicator}</b></span>
			`;return`<div class="channels f-grid g-2">${n}</div>`}};function ct(a){a.addEventListener("click",e=>{e.currentTarget.deviceStateComponent.create()})}function lt(a,e,t){return typeof pe[a]!="undefined"?pe[a](e,t):"Unknown device type<br>"+JSON.stringify(t)}function y(a,e,t){let n=Helper.template.createElement("div",{class:"component device-state-component"},"");return n.deviceStateComponent={create:()=>{n.innerHTML=Helper.template.circleLoaderHTML(),a.devices.status(e,(s,i,c)=>{if(console.log("sh_api.devices.status",s,i),!i)return n.innerHTML=`
						<span class="badge badge-error"><i class="ph ph-warning-octagon fs-lg normalize"></i> Loading Error</span>
					`,console.error("deviceStateComponent",`DeviceID ${e}`);n.innerHTML=lt(t,i.data.device.alias,i.data.device.device_response),ct(n)})}},n.deviceStateComponent.create(),n}function dt(a,e,t){let n=[{payloadFieldName:"name",selector:".display-name",methName:"update_name",originalValue:e.name,isMultiString:!1},{payloadFieldName:"description",selector:".description",methName:"update_description",originalValue:e.description,isMultiString:!0},{payloadFieldName:"new_alias",selector:".alias",methName:"update_alias",originalValue:e.alias,isMultiString:!1}];for(let s of n){let i=editableString(t.querySelector(s.selector));i.editableString.onChange(c=>{let r={device_id:e.id};r[s.payloadFieldName]=c.value,a.devices[s.methName](r,(o,l,d)=>{var u,m,p;if(o||!l||!l.status)return console.error(`sh_api.devices.${s.methName}`,o),i.editableString.setValue(s.originalValue),Toasts.createError((u=o==null?void 0:o.message)!=null?u:"Error updating",(p=(m=o.raw)==null?void 0:m.msg)!=null?p:`Error of ${s.payloadFieldName} updating`).show();l.status==!0&&Screens.reinit()})})}}function R(a,e){return console.log(a),Modals.create("device-popup",{title:`Device ${a.name}`,body:t=>{var c;let n={area_id:"place-in-area-component-container",ip:"device-ip",state:"state-container",name:"display-name",description:"description",alias:"alias-view-container"},s=(r,o)=>{let l={ip:"<code>{{value}}</code>",status:d=>`<span class="badge ${{active:"badge-success",removed:"badge-error",freezed:"badge-warning"}[d]}">${d}</span>`,connection_status:d=>`<span class="badge ${d=="active"?"badge-success":"badge-warning"}">${d}</span>`,mac:"<code>{{value}}</code>",alias:'<i class="ph ph-link-simple-break"></i> <span class="alias">{{value}}</span>',device_id:"<code>{{value}}</code>",last_contact:d=>Helper.unification.timeAgo(d),create_at:d=>Helper.unification.formatDate(d),update_at:d=>Helper.unification.formatDate(d)};return l[r]?typeof l[r]=="function"?l[r](o):l[r].replaceAll("{{value}}",o):o},i="";for(let r in a){let o=(c=n[r])!=null?c:"";i+=`
					<tr class="table-row">
						<th>${r}: </th>
						<td class="${o}">${s(r,a[r])}</td>
					</tr>
				`}return`
				<div class="block">
					<table class="table" style="border: 0">
						<tbody class="table-body">
							${i}
						</tbody>
					</table>
				</div>
			`},actions:t=>{let n=Helper.template.createElement("button",{class:"btn btn-primary"},"Close"),s=Helper.template.createElement("button",{class:"btn btn-warning with-icon"},'<i class="ph ph-arrow-clockwise"></i> Reboot'),i=Helper.template.createElement("button",{class:"btn btn-danger with-icon"},'<i class="ph ph-trash"></i> Remove');return n.addEventListener("click",c=>{t.close()}),s.dataset.deviceId=a.id,s.dataset.deviceName=a.name,s.dataset.deviceAlias=a.alias,s.addEventListener("click",c=>{s.getAttribute("disabled")||_(e,c.currentTarget,t)}),i.addEventListener("click",c=>{i.getAttribute("disabled")||(Helper.states.btnLoadingState(i,!0),confirmPopup("Are you sure you want to remove this device?",()=>{e.devices.remove(a.id,(r,o,l)=>{Helper.states.btnLoadingState(i,!1),console.log("Was removed"),t.close(),Screens.reinit(),setTimeout(()=>{Toasts.createSuccess("Removed",`
										Device: ${a.name}<br>
										Alias: <b>${a.alias}</b><br>
										IP: <b>${a.ip}</b>
										`).show()},300)})},()=>{Helper.states.btnLoadingState(i,!1),console.log("CANCELED")}))}),[n,s,i]},onready:t=>{L(e,t.querySelector(".place-in-area-component-container"),"device",a.id,a.area_id),t.querySelector(".state-container").append(y(e,a.id,a.type)),dt(e,a,t)}})}function ut(a){let e=[];for(let t of a.devices)t=Helper.unification.deviceFieldsUnification(t),e.push({deviceName:t.name,alias:t.alias,connectionStatus:Helper.template.connectionStatusBadge(t.connection_status),state:`<div 
				class="device-state-container" 
				data-device-id="${t.id}"
				data-device-type="${t.type}"
			></div>`,ip:`<code class="code">${t.ip}</code>`,actions:`
				<div class="f-grid g-2">
					<button 
						class="btn btn-secondary btn-small details-btn" 
						data-device='${JSON.stringify(t)}'
						type="button"
					>Details</button>

					<button 
						class="btn btn-warning btn-small reboot-btn" 
						data-device-id="${t.id}" 
						data-device-name="${t.name}" 
						data-device-alias="${t.alias}" 
						type="button"
					>Reboot</button>
				</div>
			`});return e}function pt(a,e,t){a.currentScreen.DOMObject.querySelector(".main-container").innerHTML=Helper.template.table("Devices list",{deviceName:"Device name",connectionStatus:"Connect",state:"State",ip:"IP",actions:"Actions"},e,`<span class="table-meta">Total: <span class="total">${t}</span> devices</span>`)}function mt(a,e){a.currentScreen.DOMObject.querySelectorAll(".reboot-btn").forEach(t=>{t.addEventListener("click",n=>{n.currentTarget.getAttribute("disabled")||_(e,n.currentTarget)})}),a.currentScreen.DOMObject.querySelectorAll(".details-btn").forEach(t=>{t.addEventListener("click",n=>{let s=b({state:""},JSON.parse(n.currentTarget.dataset.device));R(s,e).show()})})}function me(a){return{alias:"devices",renderer:()=>Helper.template.mainTemplate(I("devices")),initer:e=>{try{a.devices.list((t,n,s)=>{if(t||!n||s.status_code!=200)throw"Err";pt(e,ut(n.data),n.data.total),mt(e,a),e.currentScreen.DOMObject.querySelectorAll(".device-state-container").forEach(i=>{i.append(y(a,i.dataset.deviceId,i.dataset.deviceType))}),e.ready()})}catch(t){return console.error("sh_api.devices.list",t),e.error("Server API ERROR","")}}}}function fe(a,e){return a=Helper.unification.deviceFieldsUnification(a),Modals.create("device-setup",{title:`Setup new device ${a.ip}`,body:t=>{let n="";for(let i in a)i[0]!="_"&&(n+=`
					<tr class="table-row">
						<th>${i}: </th>
						<td>${a[i]}</td>
					</tr>
				`);return`
				<div class="row g-6">
					<div class="col device-info">
						${`
				<div class="block">
					<table class="table" style="border: 0">
						<tbody class="table-body">
							${n}
						</tbody>
					</table>
				</div>
			`}
					</div>

					<div class="col setup-form w-100">
						<div class="block form-group">
							<label class="label">
								Device alias
								<i class="ph ph-asterisk"></i>
								<input type="text" name="alias" class="input" placeholder="Input alias">
							</label>
						</div>

						<div class="block form-group">
							<label class="label">
								Device name
								<i class="ph ph-asterisk"></i>
								<input type="text" name="name" class="input" placeholder="Input name">
							</label>
						</div>

						<div class="block form-group">
							<label class="label">
								About device
								<i class="ph ph-note-pencil"></i>
								<textarea class="input" name="description" placeholder="Input description"></textarea>
							</label>
						</div>

						<div class="alert-container"></div>
					</div>
				</div>
			`},actions:t=>{let n=Helper.template.createElement("button",{class:"btn btn-primary"},"Cancel");n.addEventListener("click",i=>{t.close()});let s=Helper.template.createElement("button",{class:"btn btn-success with-icon"},'<i class="ph ph-gear"></i> Setup');return s.addEventListener("click",i=>{if(i.currentTarget.getAttribute("disabled"))return!1;let c={device_ip:a.ip},r=document.querySelector("#device-setup .setup-form");if(r.querySelectorAll("input[type='text']").forEach(d=>{d.dispatchEvent(new Event("input",{bubbles:!0}))}),r.querySelectorAll(".label.error").length)return!1;let o=r.querySelectorAll("input"),l=r.querySelector("textarea");for(let d of o)c[d.getAttribute("name")]=d.value;c[l.getAttribute("name")]=l.value,Helper.states.btnLoadingState(s,!0),e.devices.setup_new_device(c,(d,u,m)=>{var p,g;if(Helper.states.btnLoadingState(s,!1),(d==null?void 0:d.type)=="api_error"){if(console.error("ERR! sh_api.devices.setup_new_device",d.raw),(p=d.raw)!=null&&p.failed_fields)for(let v of d.raw.failed_fields)t.querySelector(`[name="${v}"]`).parentNode.classList.add("error");if((g=d.raw)!=null&&g.msg){let v=t.querySelector(".setup-form .alert-container");v.innerHTML="",v==null||v.append(Helper.template.createAlert("error",d.raw.msg))}return!1}if(!u)return!1;o.forEach(v=>v.value=""),l.value="",t.close(),Screens.reinit(),setTimeout(()=>{Toasts.createSuccess("Setup successful",`Added new device <b>ID ${a.device_id}</b>`).show()},300)})}),[n,s]},onready:t=>{t.querySelector(".setup-form").querySelectorAll("input").forEach(s=>{s.addEventListener("input",i=>{var c;i.currentTarget.value.length?(i.currentTarget.parentNode.classList.remove("error"),(c=i.currentTarget.parentNode.parentNode.querySelector(".input-info.error"))==null||c.remove()):(i.currentTarget.parentNode.classList.add("error"),i.currentTarget.parentNode.parentNode.querySelector(".input-info.error")||i.currentTarget.parentNode.parentNode.append(Helper.template.createElement("div",{class:"input-info error"},'<i class="ph ph-warning-circle"></i> Field cannot be empty')))})})}})}function ft(a){let e=[];for(let t of a.devices)t=Helper.unification.deviceFieldsUnification(t),e.push({deviceId:t.device_id,deviceName:t.name,deviceType:t.type,status:`<span class="badge badge-primary">${t.status}</span>`,ip:`<code class="code">${t.ip}</code>`,mac:`<code class="code">${t.mac}</code>`,wifiSignal:t.wifi_signal,actions:t.status=="setup"?`
				<button 
					class="btn btn-secondary btn-small setup-btn" 
					data-device='${JSON.stringify(t)}'
					type="button"
				>Setup</button>
			`:""});return e}function vt(a,e,t){a.currentScreen.DOMObject.querySelector(".main-container").innerHTML=Helper.template.table("Found devices",{deviceId:"Device ID",deviceName:"Device name",deviceType:"Type",status:"Status",ip:"IP",mac:"Mac",wifiSignal:"Signal",actions:"Actions"},e,`<span class="table-meta">Total: <span class="total">${t}</span> devices</span>`)}function bt(a,e){a.currentScreen.DOMObject.querySelectorAll(".setup-btn").forEach(t=>{t.addEventListener("click",n=>{let s=JSON.parse(n.currentTarget.dataset.device);fe(s,e).show()})})}function ve(a){return{alias:"devices-scanning",renderer:()=>Helper.template.mainTemplate(I("scanning")),initer:e=>{a.devices.scanning_all((t,n,s)=>{if(console.log("sh_api.devices.scanning_all",t,n),s.status_code!=200)return e.error("Server API ERROR","");vt(e,ft(n.data),n.data.devices.length),bt(e,a),e.ready()})}}}var V={list:me,scanning:ve};function E(a){return Helper.template.sidebarNav([{content:'<span class="list-label"><i class="ph ph-cpu"></i> Scopes</span>',route:"/#!/scripts/scopes",is_active:a=="scopes"},{content:'<span class="list-label"><i class="ph ph-play"></i> Actions</span>',route:"/#!/scripts/actions",is_active:a=="actions"},{content:'<span class="list-label"><i class="ph ph-magnifying-glass"></i> Regular</span>',route:"/#!/scripts/regular",is_active:a=="regular"}])}function J(a,e,t){a.scripts.run({alias:e,params:{}},(n,s,i)=>{s?(t(!0),setTimeout(()=>Screens.reinit(),1e3),setTimeout(()=>Toasts.createSuccess(`${e} running`,`<b>${e}</b> running success`).show(),300)):(t(!1),setTimeout(()=>Toasts.createError(`${e} failed`,`<b>${e}</b> running failed`).show(),300))})}function W(a){return`
		<div 
			class="card device-action card-${a.state=="enabled"?"primary":"warning"} script-action" 
			data-alias="${a.alias}"
		>
			<span class="card-title">${a.name} 
				<button 
					class="btn-icon without-hover action-details-btn" 
					data-alias='${a.alias}'
				>
					<i class="ph ph-dots-three-vertical"></i>
				</button>
			</span>

			<div class="card-content">
				<div class="device-icon-container">
					<div class="device-icon">
						${a.icon}
					</div>
				</div>

				<div class="device-name mb-2">${a.description}</div>
			</div>
		</div>
	`}function Y(a,e){e.querySelector(".card-content").addEventListener("click",t=>{if(e.getAttribute("disabled"))return;Helper.states.cardScriptActionLoadingState(e,!0);let n=e.dataset.alias;J(a,n,s=>{Helper.states.cardScriptActionLoadingState(e,!1),s&&(e.classList.add("card-success"),setTimeout(()=>e.classList.remove("card-success"),1e3))})})}function be(a,e){let t=document.createElement("div");t.innerHTML=W(e);let n=t.querySelector(".card");return Y(a,n),n}function ht(a){let e=[];for(let t of a.scopes){let n=t.state=="disabled"?`<button 
					class="btn btn-success btn-small change-state-btn" 
					data-scope='${JSON.stringify(t)}'
					type="button"
					data-value="enable"
				>Enable</button>`:`<button 
					class="btn btn-warning btn-small change-state-btn" 
					data-scope='${JSON.stringify(t)}'
					type="button"
					data-value="disable"
				>Disable</button>`;e.push({name:t.name,filename:`${t.filename}<br><code><small>${t.path}</small></code>`,state:Helper.template.toogleStateBadge(t.state),actions:`
				${n}
			`})}return e}function gt(a,e,t){a.currentScreen.DOMObject.querySelector(".main-container").innerHTML=Helper.template.table("Scopes list",{name:"Scope name",filename:"Filename",state:"State",actions:"Actions"},e,`<span class="table-meta">Total: <span class="total">${t}</span> scopes</span>`)}function St(a,e){a.currentScreen.DOMObject.querySelectorAll(".change-state-btn").forEach(t=>{t.addEventListener("click",n=>{let s=n.currentTarget;if(s.getAttribute("disabled"))return;let i=s.dataset.value=="enable"?"scope_enable":"scope_disable",c=JSON.parse(s.dataset.scope);Helper.states.btnLoadingState(s,!0),e.scripts[i](c.name,(r,o,l)=>{Helper.states.btnLoadingState(s,!1),o?(setTimeout(()=>Screens.reinit(),250),Toasts.createSuccess("Request Success",`State of <b>${c.name}</b> was changed`).show()):Toasts.createError("Request failed","Scope state not changed").show()})})})}function he(a){return{title:"Scripts Scopes",alias:"scripts-scopes",renderer:()=>Helper.template.mainTemplate(E("scopes")),initer:e=>{a.scripts.scopes_list((t,n,s)=>{if(console.log("sh_api.scripts.scopes_list",t,n,s),s.status_code!=200)return e.error("Server API ERROR","");gt(e,ht(n.data),n.data.total),St(e,a),e.ready()})}}}function yt(a){let e=[];for(let t of a.scripts){let n=t.state=="disabled"?`<button 
					class="btn btn-success btn-small change-state-btn" 
					data-alias='${t.alias}'
					type="button"
					data-value="enable"
				>Enable</button>`:`<button 
					class="btn btn-warning btn-small change-state-btn" 
					data-alias='${t.alias}'
					type="button"
					data-value="disable"
				>Disable</button>`;e.push({alias:`${t.alias}<br><small class="text-muted">by ${t.created_by}</small>`,name:`${t.name}<div class="mt-1"><small>${t.description}</small></div>`,filename:`${t.filename}<br><code><small>${t.path}</small></code>`,state:Helper.template.toogleStateBadge(t.state),actions:`
				${n}
			`})}return e}function _t(a,e,t){let n={};for(let s in e)n[e[s].alias]=e[s],e[s].code="";a.currentScreen.DOMObject.provideSciptsData=n,a.currentScreen.DOMObject.querySelector(".main-container").innerHTML=Helper.template.table("Regular scripts list",{alias:"Alias",name:"Script name",filename:"Filename",state:"State",actions:"Actions"},e,`<span class="table-meta">Total: <span class="total">${t}</span> scripts</span>`)}function wt(a,e){a.currentScreen.DOMObject.querySelectorAll(".change-state-btn").forEach(t=>{t.addEventListener("click",n=>{var r;let s=n.currentTarget;if(s.getAttribute("disabled"))return;let i=s.dataset.value=="enable"?"regular_enable":"regular_disable",c=(r=a.currentScreen.DOMObject.provideSciptsData[s.dataset.alias])!=null?r:{alias:s.dataset.alias};Helper.states.btnLoadingState(s,!0),e.scripts[i](c.alias,(o,l,d)=>{Helper.states.btnLoadingState(s,!1),l?(setTimeout(()=>Screens.reinit(),250),Toasts.createSuccess("Request Success",`State of <b>${c.alias}</b> was changed`).show()):Toasts.createError("Request failed","Regular script state not changed").show()})})})}function ge(a){return{title:"Scripts Regular",alias:"scripts-regular",renderer:()=>Helper.template.mainTemplate(E("regular")),initer:e=>{a.scripts.regular_list((t,n,s)=>{if(console.log("sh_api.scripts.regular_list",t,n,s),s.status_code!=200)return e.error("Server API ERROR","");_t(e,yt(n.data),n.data.total),wt(e,a),e.ready()})}}}function Se(a,e){return console.log("actionDetailsPopup",a),Modals.create("action-script-popup",{title:`${a.name}`,body:t=>{let n=a.area_id!=-1?'<div class="mt-8 mb-8 place-in-area-component-container"></div>':"";return`
				<div class="block">
					<div class="row g-4">
						<div class="col script-info w-100">
							<h4 class="alias"><i class="ph ph-link-simple-break normalize"></i> <code>${a.alias}</code></h4>
							<div class="description mt-3">${a.description}</div>
							<div class="state mt-10">${Helper.template.toogleStateBadge(a.state)}</div>
							${n}
							<div class="filename mt-4"><i class="ph ph-file-code normalize"></i> ${a.filename}</div>
							<div class="author mt-4 text-muted"><i class="ph ph-user normalize"></i> By ${a.author}</div>
						</div>
						<div class="col script-code w-200">
							<div class="script-code-view">
								<pre><code class="language-php code-viewer fs-xs">${a.code}</code></pre>
							</div>
						</div>
					</div>
				</div>
			`},actions:t=>{let n=Helper.template.createElement("button",{class:"btn btn-primary"},"Close"),s=Helper.template.createElement("button",{class:a.state=="enabled"?"btn btn-warning":"btn btn-success","data-value":a.state=="enabled"?"disable":"enable"},a.state=="enabled"?"Disable":"Enable"),i=Helper.template.createElement("button",{class:"btn btn-secondary with-icon"},'<i class="ph ph-play"></i> Run');return n.addEventListener("click",c=>{t.close()}),s.addEventListener("click",c=>{let r=c.currentTarget;if(r.getAttribute("disabled"))return;let o=r.dataset.value=="enable"?"action_enable":"action_disable";Helper.states.btnLoadingState(r,!0),e.scripts[o](a.alias,(l,d,u)=>{Helper.states.btnLoadingState(r,!1),t.close(),d?(setTimeout(()=>Screens.reinit(),250),Toasts.createSuccess("Request Success",`State of <b>${a.alias}</b> was changed`).show()):Toasts.createError("Request failed","Regular script state not changed").show()})}),i.addEventListener("click",c=>{let r=c.currentTarget;Helper.states.btnLoadingState(r,!0),J(e,a.alias,o=>{Helper.states.btnLoadingState(r,!1),o&&t.close()})}),[n,s,i]},onready:t=>{L(e,t.querySelector(".place-in-area-component-container"),"action",a.id,a.area_id),hljs.highlightElement(t.querySelector(".code-viewer"))}})}function G(a){var t,n,s;let e=[];for(let i of a.scripts)e.push({alias:i.alias,author:i.created_by,name:i.name,icon:(t=i.icon)!=null?t:'<i class="ph ph-play"></i>',description:i.description,filename:`${i.filename}<br><code><small>${i.path}</small></code>`,state:i.state,code:i.code,id:(n=i.id)!=null?n:0,area_id:(s=i.area_id)!=null?s:-1});return e}function Lt(a,e,t){let n='<div class="f-grid g-5 w-100">',s={};for(let c of e)s[c.alias]=c,n+=W(c);n+="</div>";let i=a.currentScreen.DOMObject.querySelector(".main-container");i.innerHTML=n,a.currentScreen.DOMObject.provideSciptsData=s}function Et(a,e){a.currentScreen.DOMObject.querySelectorAll(".script-action").forEach(t=>{Y(e,t)}),a.currentScreen.DOMObject.querySelectorAll(".action-details-btn").forEach(t=>{t.addEventListener("click",n=>{var c;let s=n.currentTarget,i=(c=a.currentScreen.DOMObject.provideSciptsData[s.dataset.alias])!=null?c:{};console.log("SCRIPT",i),Se(i,e).show()})})}function ye(a){return{title:"Scripts Actions",alias:"scripts-actions",renderer:()=>Helper.template.mainTemplate(E("actions")),initer:e=>{a.scripts.actions_list((t,n,s)=>{if(console.log("sh_api.scripts.actions_list",t,n,s),s.status_code!=200)return e.error("Server API ERROR","");Lt(e,G(n.data),n.data.total),Et(e,a),e.ready()})}}}var x={scopes:he,regular:ge,actions:ye};function _e(a){return Helper.template.sidebarNav([{content:'<span class="list-label"><i class="ph ph-tree-structure"></i> Areas Tree</span>',route:"/#!/areas/tree",is_active:a=="areas-tree"}])}function we(a,e){return console.log("areaDevicesModal",a),Modals.create("area-devices-modal",{title:`<i class="ph ph-map-trifold normalize"></i> ${a.display_name}`,body:t=>`
				<div class="loader"></div>
				<div class="devices-container h-100"></div>
			`,actions:t=>{let n=Helper.template.createElement("button",{class:"btn btn-primary"},"Close"),s=Helper.template.createElement("button",{class:"btn btn-warning with-icon btn-reboot-all"},'<i class="ph ph-arrow-clockwise"></i> Reboot All');return n.addEventListener("click",i=>{t.close()}),s.addEventListener("click",i=>{s.getAttribute("disabled")||(Helper.states.btnLoadingState(s,!0),confirmPopup(`Are you sure you want to reboot all devices from <b>${a.display_name}</b>?`,()=>{e.areas.reboot_devices(a.id,(c,r,o)=>{Helper.states.btnLoadingState(s,!1),r?(console.log("Was rebooted all devices"),Toasts.createSuccess("Rebooted all devices",`Area: <b>${a.display_name}</b>`).show()):Toasts.createDanger("Rebooted fail",`Area: <b>${a.display_name}</b>`).show()})},()=>{Helper.states.btnLoadingState(s,!1),console.log("CANCELED")}))}),[n,s]},onready:t=>{let n=t.querySelector(".devices-container"),s=t.querySelector(".loader");e.areas.devices(a.id,(i,c,r)=>{console.log("sh_api.areas.devices",c);function o(d){if(!d)return[];let u=[];for(let m of d.devices)m=Helper.unification.deviceFieldsUnification(m),u.push({deviceNaming:`
								<div class="device-name">${m.name}</div>
								<div class="device-alias mt-2 text-muted"><i class="ph ph-link-simple-break normalize"></i> ${m.alias}</div>
							`,status:Helper.template.connectionStatusBadge(m.connection_status),state:`<div 
									class="device-state-container"
									data-device-id="${m.id}"
									data-device-type="${m.type}"
								></div>
							`,actions:`
							<div class="f-grid g-2">
								<button 
									class="btn btn-secondary btn-small details-btn" 
									data-device='${JSON.stringify(m)}'
									type="button"
								>Details</button>

								<button 
									class="btn btn-warning btn-small reboot-btn" 
									data-device-id="${m.id}" 
									data-device-name="${m.name}" 
									data-device-alias="${m.alias}" 
									type="button"
								>Reboot</button>
							</div>
							`});return u}let l=o(c==null?void 0:c.data);l.length?n.innerHTML=Helper.template.table("",{deviceNaming:"Device",status:"Status",state:"State",actions:"Actions"},l,`<span class="table-meta">Total: <span class="total">${l.length}</span> devices</span>`):(n.innerHTML=Helper.template.emptyHereHTML(),t.querySelector(".btn-reboot-all").remove()),n.querySelectorAll(".reboot-btn").forEach(d=>{d.addEventListener("click",u=>{d.getAttribute("disabled")||_(e,u.currentTarget,t)})}),n.querySelectorAll(".device-state-container").forEach(d=>{d.append(y(e,d.dataset.deviceId,d.dataset.deviceType))}),n.querySelectorAll(".details-btn").forEach(d=>{d.addEventListener("click",u=>{let m=b({status:""},JSON.parse(u.currentTarget.dataset.device));R(m,e).show()})}),s.remove(),console.log("devices",l)})}})}function Le(a,e){return console.log("areaActionsModal",a),Modals.create("area-actions-modal",{title:`<i class="ph ph-map-trifold normalize"></i> ${a.display_name}`,body:t=>`
				<div class="loader"></div>
				<div class="actions-container f-grid g-4 h-100">
				</div>
			`,actions:t=>{let n=Helper.template.createElement("button",{class:"btn btn-primary"},"Close");return n.addEventListener("click",s=>{t.close()}),[n]},onready:t=>{let n=t.querySelector(".actions-container"),s=t.querySelector(".loader");e.areas.scripts(a.id,(i,c,r)=>{if(console.log("sh_api.areas.scripts",i,c,r),r.status_code!=200)return Toasts.createDanger("Loading failed",`Area: <b>${a.display_name}</b>`).show();let o=G(c.data);n.innerHTML="",o.length||(n.innerHTML=Helper.template.emptyHereHTML()),s.remove();for(let l of o)n.append(be(e,l))})}})}function Ee(a){return console.log("createNewAreaModal"),Modals.create("create-area-modal",{title:'<i class="ph ph-plus normalize"></i> Create new Area',body:e=>`
				<div class="create-area-form">
					<div class="block form-group">
						<label class="label">
							Type
							<input type="text" class="input" name="type" placeholder="Input Area Type">
						</label>
						<div class="advanced-select-container"></div>
					</div>

					<div class="block form-group">
						<label class="label">
							Alias
							<i class="ph ph-link-simple-break"></i>
							<input type="text" class="input" name="alias" placeholder="Input Area Alias">
						</label>
					</div>

					<div class="block form-group">
						<label class="label">
							Display Name
							<i class="ph ph-tag"></i>
							<input type="text" class="input" name="display_name" placeholder="Input Display Name">
						</label>
					</div>

					<div class="alert-container"></div>
				</div>
			`,actions:e=>{let t=Helper.template.createElement("button",{class:"btn btn-primary"},"Close"),n=Helper.template.createElement("button",{class:"btn btn-success with-icon"},'<i class="ph ph-plus"></i> Create');return t.addEventListener("click",s=>{e.close()}),n.addEventListener("click",s=>{let i=e.querySelector(".create-area-form");if(i.querySelectorAll("input[type='text']").forEach(o=>{o.dispatchEvent(new Event("input",{bubbles:!0}))}),i.querySelectorAll(".label.error").length)return!1;let c=i.querySelectorAll("input"),r={};for(let o of c)r[o.getAttribute("name")]=o.value;Helper.states.btnLoadingState(n,!0),a.areas.new_area(r,(o,l,d)=>{var u,m;if(Helper.states.btnLoadingState(n,!1),(o==null?void 0:o.type)=="api_error"){if(console.error("ERR! sh_api.areas.new_area",o.raw),(u=o.raw)!=null&&u.failed_fields)for(let p of o.raw.failed_fields)e.querySelector(`[name="${p}"]`).parentNode.classList.add("error");if((m=o.raw)!=null&&m.msg){let p=e.querySelector(".alert-container");p.innerHTML="",p==null||p.append(Helper.template.createAlert("error",o.raw.msg))}return!1}if(!l)return!1;c.forEach(p=>p.value=""),e.close(),Screens.reinit(),setTimeout(()=>{Toasts.createSuccess("Creating successful",`Added new area <b>ID ${r.alias}</b>`).show()},300)})}),[t,n]},onready:e=>{let t=e.querySelector(".create-area-form");t.querySelectorAll(".input").forEach(n=>{n.addEventListener("input",s=>{var i;s.currentTarget.value.length?(s.currentTarget.parentNode.classList.remove("error"),(i=s.currentTarget.parentNode.parentNode.querySelector(".input-info.error"))==null||i.remove()):(s.currentTarget.parentNode.classList.add("error"),s.currentTarget.parentNode.parentNode.querySelector(".input-info.error")||s.currentTarget.parentNode.parentNode.append(Helper.template.createElement("div",{class:"input-info error"},'<i class="ph ph-warning-circle"></i> Field cannot be empty')))})}),a.areas.types_list((n,s,i)=>{console.log("sh_api.areas.types_list",n,s,i),s||console.error("Request Error. sh_api.areas.types_list()");let c={};for(let r of s.data.types)c[r]=r;t.querySelector(".advanced-select-container").append(advancedSelect(t.querySelector('[name="type"]'),c,"Will be created"))})}})}function $t(a,e,t){let n=[{payloadFieldName:"display_name",selector:".display-name",methName:"update_display_name",originalValue:e.display_name,isMultiString:!1},{payloadFieldName:"new_alias",selector:".alias",methName:"update_alias",originalValue:e.alias,isMultiString:!1}];for(let s of n){let i=editableString(t.querySelector(s.selector));i.editableString.onChange(c=>{let r={area_id:e.id};r[s.payloadFieldName]=c.value,a.areas[s.methName](r,(o,l,d)=>{var u,m,p;if(o||!l||!l.status)return console.error(`sh_api.areas.${s.methName}`,o),i.editableString.setValue(s.originalValue),Toasts.createError((u=o==null?void 0:o.message)!=null?u:"Error updating",(p=(m=o.raw)==null?void 0:m.msg)!=null?p:`Error of ${s.payloadFieldName} updating`).show();l.status==!0&&Screens.reinit()})})}}function $e(a,e){var t;return a=(t=Screens.currentScreen.DOMObject.provideData[a.id])!=null?t:a,console.log("areaDetailsModal",a),Modals.create("area-details-modal",{title:`<i class="ph ph-map-trifold normalize"></i> ${a.display_name}`,body:n=>{var o;let s=a,i={parent_id:"place-in-area-container",display_name:"display-name",alias:"alias-view-container"},c=(l,d)=>{let u={alias:'<i class="ph ph-link-simple-break"></i> <span class="alias">{{value}}</span>',create_at:m=>Helper.unification.formatDate(m),update_at:m=>Helper.unification.formatDate(m),schema:"<span class='text-mute'>Nothing yet</span>"};return u[l]?typeof u[l]=="function"?u[l](d):u[l].replaceAll("{{value}}",d):d},r="";for(let l in s){let d=(o=i[l])!=null?o:"";r+=`
					<tr class="table-row">
						<th>${l}: </th>
						<td class="${d}">${c(l,s[l])}</td>
					</tr>
				`}return`
				<table class="table" style="border: 0">
					<tbody class="table-body">
						${r}
					</tbody>
				</table>
			`},actions:n=>{let s=Helper.template.createElement("button",{class:"btn btn-primary"},"Close"),i=Helper.template.createElement("button",{class:"btn btn-danger with-icon"},'<i class="ph ph-trash"></i> Remove');return s.addEventListener("click",c=>{n.close()}),i.addEventListener("click",c=>{Helper.states.btnLoadingState(i,!0),confirmPopup(`Are you sure you want to remove this area? <b>${a.display_name}</b>`,()=>{e.areas.remove(a.id,(r,o,l)=>{Helper.states.btnLoadingState(i,!1),console.log("Was removed"),n.close(),Screens.reinit(),setTimeout(()=>{Toasts.createSuccess("Removed",`Area: ${a.display_name}`).show()},300)})},()=>{Helper.states.btnLoadingState(i,!1),console.log("CANCELED")})}),[s,i]},onready:n=>{L(e,n.querySelector(".place-in-area-container"),"area",a.id,a.parent_id),$t(e,a,n)}})}function Tt(a){let e=a.areas,t={},n=[];for(let s of e)t[s.id]=ne(b({},s),{children:[]});for(let s of e){let i=t[s.id];s.parent_id&&t[s.parent_id]?t[s.parent_id].children.push(i):n.push(i)}return n}function Ht(a){return Tt(a)}function Te(a,e){var s,i;e=e!=null?e:0;let t=(s=a.children)!=null&&s.length?"":"is-single",n=`
		<div class="branch lvl-${e} ${t}" data-lvl="${e}">
			<button class="btn-icon without-hover show-childs">
				<i class="ph ph-caret-right"></i>
			</button>
			<div class="branch-container">
				<div class="branch-info">
					<span class="title"><i class="ph ph-map-trifold normalize"></i> ${a.display_name}</span>
					[
					<span class="text-muted area-type">${a.type}</span>
					<span><i class="ph ph-link-simple-break normalize"></i> ${a.alias}</span>
					]
				</div>

				<div class="row g-4">
					<button 
						class="btn btn-accent btn-small with-icon actions"
						data-area-id="${a.id}"
						data-area-name="${a.display_name}"
					><i class="ph ph-brackets-curly"></i> Actions</button>
					<button 
						class="btn btn-accent btn-small with-icon devices" 
						data-area-id="${a.id}"
						data-area-name="${a.display_name}"
					><i class="ph ph-cpu"></i> Devices</button>
					<button 
						class="btn btn-small btn-primary details"
						data-area-id="${a.id}"
						data-area-name="${a.display_name}"
						data-parent-id="${a.parent_id}"
					>Details</button>
				</div>
			</div>
		</div>
	`;if((i=a.children)!=null&&i.length)for(let c of a.children)n+=Te(c,e+1);return n}function At(a,e){console.log("TREE",e);let t='<div class="tree">';for(let n of e)t+=Te(n);t+="</div>",a.currentScreen.DOMObject.querySelector(".main-container .tree-container").innerHTML=t}function Dt(a,e){a.currentScreen.DOMObject.querySelectorAll(".btn.devices").forEach(t=>{t.addEventListener("click",n=>{we({id:n.currentTarget.dataset.areaId,display_name:n.currentTarget.dataset.areaName},e).show()})}),a.currentScreen.DOMObject.querySelectorAll(".btn.actions").forEach(t=>{t.addEventListener("click",n=>{Le({id:n.currentTarget.dataset.areaId,display_name:n.currentTarget.dataset.areaName},e).show()})}),a.currentScreen.DOMObject.querySelectorAll(".btn.details").forEach(t=>{t.addEventListener("click",n=>{$e({id:n.currentTarget.dataset.areaId,display_name:n.currentTarget.dataset.areaName,parent_id:n.currentTarget.dataset.parentId},e).show()})}),a.currentScreen.DOMObject.querySelectorAll("button.show-childs").forEach(t=>{t.addEventListener("click",n=>{let s=n.currentTarget,i=s.parentNode,c=parseInt(i.dataset.lvl);if(s.classList.contains("opened")){s.classList.remove("opened");let r=i.nextElementSibling;for(;r;){let o=parseInt(r.dataset.lvl);if(o==c||o<c)break;o==c+1&&r.classList.remove("a-show"),r=r.nextElementSibling}}else{s.classList.add("opened");let r=i.nextElementSibling;for(;r;){let o=parseInt(r.dataset.lvl);if(o==c||o<c)break;o==c+1&&r.classList.add("a-show"),r=r.nextElementSibling}}})}),a.ready()}function He(a){return{title:"Areas Tree",alias:"areas-tree",renderer:()=>Helper.template.mainTemplate(_e("areas-tree"),`<div class="top-bar">
					<div class="row g-4">
						<div class="col">
							<h3 class="title">Areas Tree</h3>
						</div>
						<div class="col">
							<button class="btn btn-primary with-icon create-new-area-modal">
								<i class="ph ph-plus"></i>
								Create
							</button>
						</div>
					</div>
				</div>
				<div class="mt-6 tree-container"></div>
				`),initer:e=>{a.areas.list((t,n,s)=>{if(console.log("sh_api.areas.list",t,n,s),s.status_code!=200)return e.error("Server API ERROR","");if(e.currentScreen.DOMObject.provideData={},typeof n.data!="undefined"&&typeof n.data.areas!="undefined")for(let c of n.data.areas)e.currentScreen.DOMObject.provideData[c.id]=c;At(e,Ht(n.data)),Dt(e,a);let i=e.currentScreen.DOMObject.querySelector(".create-new-area-modal");i.classList.contains("inited")||(i.classList.add("inited"),i==null||i.addEventListener("click",c=>{Ee(a).show()})),e.ready()})}}}var Ae={areasTree:He};function De(a,e){a.add("/",{alias:"home",renderer:()=>"",initer:t=>{document.location="/#!/areas/tree"}}),a.add("-",{alias:"not-found-screen",renderer:()=>'<div class="container"><h2 class="mt-4">404 NOT FOUND</h2></div>',initer:t=>{t.ready()}}),a.add("/devices",V.list(e)),a.add("/devices/scanning",V.scanning(e)),a.add("/scripts/scopes",x.scopes(e)),a.add("/scripts/regular",x.regular(e)),a.add("/scripts/actions",x.actions(e)),a.add("/areas/tree",Ae.areasTree(e))}function Mt(a,e,t){return`
		<div class="modal" aria-hidden="true" id="${a}">
      <div class="modal-backdrop"></div>

      <div class="modal-panel" role="dialog" aria-modal="true" aria-labelledby="modal-title-basic">
        <header class="modal-header">
          <h4 class="modal-title" id="modal-title-basic">${e}</h4>
          <button class="btn-icon modal-close" type="button" aria-label="Close">\u2715</button>
        </header>

        <div class="modal-body"></div>
        <footer class="modal-footer">${t}</footer>
      </div>
    </div>
	`}function qt(a,e){return a.show=function(){document.querySelector("body").append(a),setTimeout(()=>{a.classList.add("a-show")},10)},a.close=function(){a.classList.add("a-hide"),setTimeout(()=>{a.remove()},300)},a.querySelector(".modal-close").addEventListener("click",t=>{a.close()}),typeof e=="function"&&e(a),a}function Ot(a,e){let t=e.title||"",n=e.footer||"",s=document.createElement("div");s.innerHTML=Mt(a,t,n);let i=s.childNodes[1],c=i.querySelector(".modal-body"),r=i.querySelector(".modal-footer");if(typeof e.actions=="function"){let o=e.actions(i);if(typeof o[0]=="object"){let l=document.createElement("div");l.classList.add("actions");for(let d of o)l.append(d);r.append(l)}}if(typeof e.body=="function"){let o=e.body(i);typeof o=="object"?c.append(o):typeof o=="string"&&(c.innerHTML=o)}return qt(i,e==null?void 0:e.onready)}var Me={create:Ot};function K(a,e,t){Modals.create("confirm-popup",{title:"Requires confirmation",body:n=>`
				<p>${a}</p>
			`,actions:n=>{let s=Helper.template.createElement("button",{class:"btn btn-primary"},"NO"),i=Helper.template.createElement("button",{class:"btn btn-warning"},"YES");return s.addEventListener("click",c=>{n.close(),t()}),i.addEventListener("click",c=>{n.close(),e()}),[s,i]}}).show()}function qe(a){let e=a.querySelector(".focus");if(!e)return;let t=a.getBoundingClientRect(),n=e.getBoundingClientRect();n.top<t.top?a.scrollTop-=t.top-n.top:n.bottom>t.bottom&&(a.scrollTop+=n.bottom-t.bottom)}function Q(a){a.advancedSelect.optionsElements.length-a.querySelectorAll(".option.hide").length==0?a.advancedSelect.showState("not-found"):a.advancedSelect.showState("options")}function X(a,e,t){let n=document.createElement("div");n.classList.add("advanced-select");let s="";for(let r in e)s+=`<div class="option" data-value="${r}" data-display-value="${e[r]}">${e[r]}</div>`;let i=`
		<div class="popup-options-container">
			<div class="not-found">${t}</div>
			<div class="options">${s}</div>
		</div>
	`;n.innerHTML=i;let c=(r,o)=>{for(let l in o)if(o[l]==r){let d={};return d[l]=o[l],d}return!1};return n.advancedSelect={isOpened:!1,options:e,eventsHandlers:{openList:[],closeList:[],selected:[],changed:[]},openList:()=>{n.advancedSelect.isOpened=!0,n.classList.add("a-show"),Q(n),n.advancedSelect.dispatchEvent("openList")},closeList:()=>{n.advancedSelect.isOpened=!1,n.classList.remove("a-show"),Q(n),n.advancedSelect.dispatchEvent("closeList")},showState:r=>{r=="options"?(n.querySelector(".options").classList.add("show"),n.querySelector(".not-found").classList.remove("show")):r=="not-found"&&(n.querySelector(".options").classList.remove("show"),n.querySelector(".not-found").classList.add("show"))},optionsElements:n.querySelectorAll(".option"),value:()=>{let r=c(a.value,e);return{inputValue:a.value,isOption:!!r,option:r}},addEventListener:(r,o)=>{if(typeof n.advancedSelect.eventsHandlers[r]!="undefined")return n.advancedSelect.eventsHandlers[r].push(o);console.error("Advanced Select component.","addEventListener()","Invalid event name")},dispatchEvent:r=>{if(typeof n.advancedSelect.eventsHandlers[r]=="undefined")return console.error("Advanced Select component.","dispatchEvent()","Invalid event name");for(let o of n.advancedSelect.eventsHandlers[r])o(n)}},a.setAttribute("autocomplete","nope"),a.advancedSelect={value:()=>n.advancedSelect.value()},a.addEventListener("focus",r=>{n.advancedSelect.openList()}),a.addEventListener("blur",r=>{setTimeout(()=>n.advancedSelect.closeList(),20)}),a.addEventListener("keydown",r=>{if(r.keyCode==38){let o=n.querySelector(".option.focus");if(o){o.classList.remove("focus");let l=o.previousElementSibling;for(;l&&l.classList.contains("hide");)l=l.previousElementSibling;l||(l=n.querySelector(".option:not(.hide)")),l.classList.add("focus")}else n.querySelector(".option:not(.hide):last-child").classList.add("focus");qe(n)}else if(r.keyCode==40){let o=n.querySelector(".option.focus");if(o){o.classList.remove("focus");let l=o.nextElementSibling;for(;l&&l.classList.contains("hide");)l=l.nextElementSibling;l||(l=n.querySelector(".option:not(.hide)")),l.classList.add("focus")}else n.querySelector(".option:not(.hide)").classList.add("focus");qe(n)}else if(r.keyCode==13){let o=n.querySelector(".option.focus");if(!o)return;a.value=o.dataset.displayValue,a.blur(),a.dispatchEvent(new Event("input",{bubbles:!0})),a.dispatchEvent(new Event("change",{bubbles:!0})),n.advancedSelect.dispatchEvent("selected")}}),a.addEventListener("input",r=>{var l;let o=r.currentTarget.value.toLowerCase();o==""?n.advancedSelect.optionsElements.forEach(d=>d.classList.remove("hide")):([...n.advancedSelect.optionsElements].filter(d=>d.dataset.displayValue.toLowerCase().indexOf(o)!=-1).forEach(d=>d.classList.remove("hide")),[...n.advancedSelect.optionsElements].filter(d=>d.dataset.displayValue.toLowerCase().indexOf(o)==-1).forEach(d=>d.classList.add("hide")),Q(n),(l=n.querySelector(".option.focus"))==null||l.classList.remove("focus"))}),a.addEventListener("change",r=>{n.advancedSelect.dispatchEvent("changed")}),[...n.advancedSelect.optionsElements].forEach(r=>{r.addEventListener("click",o=>{a.value=o.currentTarget.dataset.displayValue,a.blur(),a.dispatchEvent(new Event("input",{bubbles:!0})),a.dispatchEvent(new Event("change",{bubbles:!0})),n.advancedSelect.dispatchEvent("selected")})}),n}function Ct(a,e){let t="Write something",n=e?`<textarea class="input" placeholder="${t}"></textarea>`:`<input type="text" class="input" placeholder="${t}">`;return`
		<div class="editable-string-content">
			<span class="editable-string">${a}</span>
			<button class="btn-icon without-hover edit-text-btn"><i class="ph ph-pencil-simple"></i></button>
		</div>
		<div class="editable-string-form d-none">
			<div class="form-group">
				<label class="label">
					${n}
				</label>
			</div>
			<button class="btn-icon without-hover apply-changes-btn"><i class="ph ph-check"></i></button>
			<button class="btn-icon without-hover cancel-changes-btn"><i class="ph ph-x"></i></button>
		</div>
	`}function Z(a,e){e=e!=null?e:!1;let t=a.innerHTML,n=Helper.template.createElement("div",{class:"component editable-string-component"},Ct(t,e));a.innerHTML="",a.append(n);let s=n.querySelector(".edit-text-btn"),i=n.querySelector(".apply-changes-btn"),c=n.querySelector(".cancel-changes-btn"),r=n.querySelector(".editable-string-content"),o=n.querySelector(".editable-string"),l=n.querySelector(".editable-string-form"),d=n.querySelector(".input");return n.editableString={formIsDisplaying:!1,value:t,input:d,eventsHandlers:{onChange:[],onSwitch:[]},switch:()=>{n.formIsDisplaying?(l.classList.add("d-none"),r.classList.remove("d-none"),o.innerText=n.editableString.value):(l.classList.remove("d-none"),r.classList.add("d-none"),d.value=n.editableString.value),n.formIsDisplaying=!n.formIsDisplaying,n.editableString.runEventHandler("onSwitch")},setValue:u=>{n.editableString.value=u,d.value=u,o.innerText=u},apply:()=>{n.editableString.value=d.value,n.editableString.switch(),d.value!=t&&n.editableString.runEventHandler("onChange")},onChange:u=>{n.editableString.eventsHandlers.onChange.push(u)},onSwitch:u=>{n.editableString.eventsHandlers.onSwitch.push(u)},runEventHandler:u=>{n.editableString.eventsHandlers[u].forEach(m=>m(n.editableString))}},s.addEventListener("click",u=>{n.editableString.switch()}),c.addEventListener("click",u=>{n.editableString.switch()}),i.addEventListener("click",u=>{n.editableString.apply()}),d.addEventListener("keydown",u=>{u.keyCode==13&&(d.blur(),n.editableString.apply())}),n}document.addEventListener("DOMContentLoaded",a=>{console.log("App init"),document.location.hash.indexOf("#!/")==-1&&(document.location.hash="#!/"),window.Toasts=oe,window.Helper=le,window.Modals=Me,window.confirmPopup=K,window.advancedSelect=X,window.editableString=Z,ie();let e=new k({base_url:API_BASEURL,token:"YOUR_TOKEN",timeout_ms:1e4,on_unauthorized:({error:n})=>console.log("auth problem:",n),proxy_path:"/proxy.php"}),t=new M(".screens",".load-screen",".error-screen");De(t,e),console.log(t.getScreens()),t.onSwitch((n,s)=>{F()}),t.onSwitch((n,s,i)=>{var c;document.querySelectorAll(".app .hud .navigation .nav-link[data-route].active").forEach(r=>r.classList.remove("active")),(c=document.querySelector(`.app .hud .navigation .nav-link[data-route="${i}"]`))==null||c.classList.add("active")}),t.routing(),window.Screens=t});})();
//# sourceMappingURL=main.js.map
