const navigationHeader=function(){const body=document.querySelector("body");const burgerMenu=document.querySelector(".toggle.burger-menu");const closeBtn=document.querySelector(".toggle.close-button");const mobileHeader=document.querySelector(".mobile-header");const menuItem=document.querySelectorAll(".menu.mobile");const subMenus=document.querySelectorAll(".menu.mobile .submenu");const language=document.querySelector(".language");const languageMobile=document.querySelector(".language-mobile");const languageSubmenu=document.querySelector(".language .submenu");const languageMobileSubmenu=document.querySelector(".language-mobile .submenu");const navigationHeader=document.getElementById("navigation-headerv2");let currentSubmenu;function closeMenu(){burgerMenu.classList.remove("active");closeBtn.classList.add("active");mobileHeader.classList.add("active");navigationHeader.style.bottom="0";body.style.overflow="hidden"}function openMenu(){closeBtn.classList.remove("active");burgerMenu.classList.add("active");mobileHeader.classList.remove("active");navigationHeader.style.bottom="";body.style.overflow="scroll";subMenus.forEach((item=>{if(item.classList.contains("active")){item.classList.remove("active")}}))}function showTranslate(){if(languageSubmenu.classList.contains("active")){languageSubmenu.classList.remove("active")}else{languageSubmenu.classList.add("active")}}function showTranslateMobile(){if(languageMobileSubmenu.classList.contains("active")){languageMobileSubmenu.classList.remove("active")}else{languageMobileSubmenu.classList.add("active")}}function showSubmenu(e){const submenu=e.currentTarget.children[1];if(submenu.classList[1]===currentSubmenu){submenu.classList.remove("active");currentSubmenu=null}else{subMenus.forEach((item=>{item.classList.remove("active")}));submenu.classList.add("active");currentSubmenu=submenu.classList[1]}}if(burgerMenu){burgerMenu.addEventListener("click",closeMenu)}if(closeBtn){closeBtn.addEventListener("click",openMenu)}if(menuItem.length){menuItem.forEach((item=>{item.addEventListener("click",(e=>showSubmenu(e)))}))}if(language){language.addEventListener("click",showTranslate)}if(languageMobile){languageMobile.addEventListener("click",showTranslateMobile)}function renderServersStock(data){renderCommonServersStock(data.filter((item=>item.location.includes("US"))).length,data.filter((item=>item.location.includes("EU"))).length)}function renderApiServersStock(){fetch("/api/readyservers/config?count=1",{method:"GET",headers:{"Content-type":"application/json"}}).then((response=>{if(response.status!==200){return response.status}return response.json()})).then((data=>{renderCommonServersStock(data.us,data.eu)}))}function renderCommonServersStock(unitesStatesServersCount,europeServersCount){const totalCount=unitesStatesServersCount+europeServersCount;const isMobile=window.matchMedia("(max-width: 1024px)").matches;const date=new Date;let hour=date.getHours();hour=hour<10?`0${hour}`:hour;let minutes=date.getMinutes();minutes=minutes<10?`0${minutes}`:minutes;const container=document.querySelectorAll(".servers-stock-count-container");const currentTimeElement=document.querySelectorAll(".current-stock-time");const stockTextInfo=document.querySelectorAll(".stock-text-info");const stockPlaceholder=document.querySelectorAll(".stock-placeholder");if(container&&container.length&¤tTimeElement&¤tTimeElement.length&&stockTextInfo&&stockTextInfo.length&&stockPlaceholder&&stockPlaceholder.length){currentTimeElement.forEach((item=>{item.innerHTML=` ${hour}:${minutes}`}));if(!isMobile){container.forEach((item=>{item.innerHTML=`\n : \n
${unitesStatesServersCount} x United States
\n \n \n \n${europeServersCount} x Europe
\n `}))}else{stockTextInfo.forEach((item=>item.classList.remove("d-none")));stockPlaceholder.forEach((item=>item.classList.add("d-none")));container.forEach((item=>item.innerHTML=` ${totalCount} `))}}}(function checkTokenIsValid(){const localStorageKeys={token:"token",userInfoLoginData:"userInfoLoginData"};const token=localStorage.getItem(localStorageKeys.token);const userInfoLoginData=localStorage.getItem(localStorageKeys.userInfoLoginData);const userProfileAvatar=document.querySelectorAll(".user-profile-avatar");const loginBtn=document.querySelectorAll(".login-button-wrapper");if(token&&userInfoLoginData){fetch("/api/tokenvalid",{method:"GET",headers:{"Content-type":"application/json","X-Auth-Token":token,"X-Website":Website}}).then((response=>response.status)).then((data=>{if(data===200){userProfileAvatar.forEach((item=>{item.classList.remove("d-none")}))}else{loginBtn.forEach((item=>{item.classList.remove("d-none")}));localStorage.removeItem(localStorageKeys.token);localStorage.removeItem(localStorageKeys.userInfoLoginData)}}))}else{userProfileAvatar.forEach((item=>{item.classList.add("d-none")}));loginBtn.forEach((item=>{item.classList.remove("d-none")}));localStorage.removeItem(localStorageKeys.token);localStorage.removeItem(localStorageKeys.userInfoLoginData)}})();document.querySelectorAll(".dropdown__menu-link").forEach((element=>{element.addEventListener("click",(event=>{element=event.currentTarget;let lang=element.dataset.id;let currentLocation=window.location.pathname;let regLang=/^(\/\w\w|)(\/.*)/;let match=regLang.exec(currentLocation);const request={endpoint:"/translate_serv.php",options:{method:"POST",headers:{"Content-type":"application/x-www-form-urlencoded; charset=UTF-8"},body:"language="+lang}};fetch(request.endpoint,request.options).then((response=>{if(response.status===200){if(lang==="null"){window.location.href="/"}else{window.location.href="/"+lang+match[2]}}})).then((data=>data)).catch((error=>console.error(error)));return false}))}));return{renderServersStock:renderServersStock,renderApiServersStock:renderApiServersStock}}();