const uiGlobal=function(){function findParent(element,value,referrence){while(element.parentNode){element=element.parentNode;if(element[referrence]===value){return element}}return null}function renderCheapestServerPrice(arr){const element=document.getElementById("cheapest-server-price");const prices=arr.map((item=>item.price));let minPrice=Math.min(...prices);minPrice=minPrice%1!==0?minPrice.toFixed(2):minPrice;if(element){element.textContent=minPrice}}const renderTableHeader=(servers,containerUI,componentsArr,hasGPU=false,discountedCustomGPU=false)=>{const tableColumnsToDisplay=[...componentsArr];if(containerUI.parentElement.classList.value==="table-configuration-header"){tableColumnsToDisplay.unshift("showMore")}tableColumnsToDisplay.push("Price");if(hasGPU){tableColumnsToDisplay.splice(2,0,"GPU")}if(discountedCustomGPU){tableColumnsToDisplay.splice(2,0,"GPU")}let tableCellHtml="";let dataCenterHtml="";tableColumnsToDisplay.forEach((item=>{let optionHTML="";let columnTitle="";let extraInfo="";let selectComponentType="";switch(item){case"showMore":selectComponentType="showMore";break;case"CPU":columnTitle="Processor(s)";selectComponentType="cpu";break;case"GPU":columnTitle=item;selectComponentType="gpu";break;case"IPv":columnTitle="IPv";break;case"FlashMedia":columnTitle="Streaming Solution";break;case"OpSoft":columnTitle="Optional Software";break;case"OS":columnTitle="OS";selectComponentType="os";break;case"RAM":columnTitle="Memory";selectComponentType="ram";extraInfo="GB";break;case"HDD":columnTitle="Storage";selectComponentType="hdd";break;case"PortSpeed":columnTitle="Transfer";selectComponentType="traffic";break;case"Location":columnTitle="Data Center";selectComponentType="location";break;case"Price":if(window.location.pathname.includes("/deals/")){columnTitle="Discount";selectComponentType="discount"}else{columnTitle="Monthly cost";selectComponentType="price"}break}if(servers){if(selectComponentType==="price"){optionHTML=`\n \n \n \n \n \n \n \n `}else if(selectComponentType==="discount"){optionHTML=`\n \n \n \n \n `}else{let selectValue=servers.map((item=>item[selectComponentType])).filter((item=>item)).sort(((a,b)=>{const numberSort=["ram","price","traffic"].includes(selectComponentType);if(numberSort&&selectComponentType==="traffic"){if(a.includes("Gbps")){a=parseInt(a.split(" ")[0])*1e3}else{a=parseInt(a.split(" ")[0])}if(b.includes("Gbps")){b=parseInt(b.split(" ")[0])*1e3}else{b=parseInt(b.split(" ")[0])}}if(a&&b){return numberSort?a-b:b.localeCompare(a)}}));selectValue=selectValue.filter(((item,index)=>selectValue.indexOf(item)===index));if(selectComponentType==="hdd"){selectValue=selectValue.map((item=>{const storageObject={memoryType:"",memorySize:-1,storageType:"",count:1};let valueString=item;const valueSplit=item.split(" x ");const hasCount=valueSplit.length>1;if(hasCount){storageObject.count=parseInt(valueSplit[0]);valueString=valueSplit[1]}[storageObject.storageType,storageObject.memorySize,storageObject.memoryType]=valueString.split(" ");storageObject.memorySize=parseFloat(storageObject.memorySize);return storageObject})).sort(((a,b)=>{if(a.count!==b.count){return a.count-b.count}if(a.storageType!==b.storageType){return a.storageType.localeCompare(b.storageType)}if(a.memoryType!==b.memoryType){return a.memoryType.localeCompare(b.memoryType)}return a.memorySize-b.memorySize})).map((item=>`${item.count>1?`${item.count} x ${item.storageType} ${item.memorySize} ${item.memoryType}`:`${item.storageType} ${item.memorySize} ${item.memoryType}`}`))}selectValue.forEach((selectValueItem=>{optionHTML+=``}))}}tableCellHtml+=`\n
\n ${columnTitle} \n\n ${servers&&selectComponentType!=="showMore"?`\n \n `:""}\n | \n `}));if(containerUI){containerUI.innerHTML=tableCellHtml}};let allPricesArray=[];function renderCustomTable(serversArray,table,componentsArr,extraData=undefined){const pathname=window.location.pathname;let tableBodyHtml="";serversArray.forEach((item=>{let totalPrice=0;let customParams="";const serverInitialData=item.data;const plan=item.type;let components=utilGlobal.getServerDefaultComponents(serverInitialData,componentsArr);const hddAvailable=["D102","D103","D104","D104a","D105","D105a","D105b","D156","D157","D158"].includes(plan)?2:1;if(extraData){if(extraData.tableType==="unmetered"&&extraData.portSpeed){components.PortSpeed=serverInitialData.PortSpeed.filter(((item,index)=>item.Value===extraData.portSpeed))[0];if(!components.PortSpeed){return}customParams+=`&preselectBandwidth=${components.PortSpeed.Value}`}if(extraData.tableType==="operatingSystem"&&extraData.os){components.OS=serverInitialData.OS.filter((item=>{if(extraData.os==="windows"&&extraData.osType){return item.Value===extraData.osType}if(extraData.os==="linux"){return!item.Value.toLowerCase().includes("windows")}}))[0];if(!components.OS){return}customParams+=`&preselectOperatingSystem=${components.OS.id}`}if(extraData.tableType==="Red5"){components.FlashMedia=serverInitialData.FlashMedia.filter((item=>{if(item.Value.includes("Red5")){return item}}))[0];if(!components.FlashMedia){return}}if(extraData.tableType==="FlashMedia"&&extraData.FlashMedia){components.FlashMedia=serverInitialData.FlashMedia.filter((item=>item.Value.toLowerCase().includes(extraData.FlashMedia)))[0];if(!components.FlashMedia){return}}if(extraData.tableType==="OpSoft"&&extraData.OpSoft){components.OpSoft=serverInitialData.OpSoft.filter((item=>item.Value.toLowerCase().includes(extraData.OpSoft)))[0];if(!components.OpSoft){return}}}if(plan==="M350"){components.PortSpeed=serverInitialData.PortSpeed[2];customParams+="&preselectBandwidth=300"}if(components.FlashMedia){customParams+=`&preselectStreaming=${components.FlashMedia.id}`}if(components.OpSoft){customParams+=`&preselectOpSoft=${components.OpSoft.id}`}const pageURL=["/artificial-intelligence/","/machine-learning/","/dedicated/gpu/pricing/","/transcoding/","/h100/","/rtx30/","/l40s/","/instinct/","/llm/"];if(pageURL.includes(window.location.pathname)){const pathName=window.location.pathname;const preselectGPUs={"/dedicated/gpu/pricing/":{D103:"NVIDIA GeForce GTX 1080 Ti 3584 CUDA Cores",D104:"NVIDIA Quadro RTX 5000 3072 CUDA Cores",D104a:"4 x NVIDIA CMP-170HX Mining GPU 164MH/s",D105:"NVIDIA Ampere A40 10752 CUDA Cores"},"/artificial-intelligence/":{D104a:"NVIDIA Tesla V100 32GB 5120 CUDA Cores",D104:"NVIDIA Ampere A40 10752 CUDA Cores",D105:"NVIDIA Ampere A100 40GB 6912 CUDA Cores"},"/machine-learning/":{D104a:"NVIDIA Tesla V100 32GB 5120 CUDA Cores",D104:"NVIDIA Ampere A40 10752 CUDA Cores",D105:"NVIDIA Ampere A100 40GB 6912 CUDA Cores"},"/transcoding/":{D103:"NVIDIA TESLA P4 / QUADRO P5000 2560 CUDA Transcoding Cores",D104:"NVIDIA Quadro RTX 5000 3072 CUDA Cores",D105:"NVIDIA RTX A6000 10752 CUDA Cores"},"/h100/":{D105:"4 x NVIDIA Ampere A100 40GB 6912 CUDA Cores"},"/rtx30/":{D104:"NVIDIA GeForce RTX 3070 5888 CUDA Cores",D105:"NVIDIA GeForce RTX 3080 8704 CUDA Cores"},"/l40s/":{D105:"NVIDIA L40S 18176 CUDA Cores"},"/instinct/":{D105:"AMD Instinct MI210"},"/llm/":{D105a:"NVIDIA H100 80GB 16896 CUDA Cores",D105b:"NVIDIA L40S 18176 CUDA Cores",D105:"NVIDIA Ampere A100 40GB 6912 CUDA Cores"}};const currObj=Object.entries(preselectGPUs).filter((val=>val[0]===pathName))[0][1];let demoArray=[];Object.entries(currObj).forEach((demo=>{let obj={};if(demo[0].includes("D104a")){obj["D104"]=demo[1]}else if(demo[0].includes("D105a")||demo[0].includes("D105b")){obj["D105"]=demo[1]}else{obj[demo[0]]=demo[1]}demoArray.push(obj)}));if(["D103","D104","D104a","D105","D105a","D105b"].includes(item.type)){components.GPU=serverInitialData.GPU.find((value=>{if(value.Value===currObj[item.type]){return value}}));customParams+=`&preselectGPU=${components.GPU.id}`}}const linkHref=utilGlobal.changeOrderLink(plan,undefined,customParams.length?customParams:"");const undefinedProperty=Object.values(components).some((item=>!item));if(undefinedProperty){return}if(Object.keys(components).length){let allPrices={CPU:components.CPU.FixedPrice,RAM:components.RAM.FixedPrice,HDD:components.HDD.PerValuePrice*hddAvailable,PortSpeed:components.PortSpeed.FixedPrice,FixedPrice:serverInitialData.FixedPrice};const operatingSystemPrice=dataModelGlobal.calculateOS({initialServerData:serverInitialData,finalOrderData:serverInitialData.DefaultConfig});Object.assign(allPrices,components.GPU?{GPU:components.GPU.FixedPrice}:undefined,components.OS?{OS:operatingSystemPrice}:undefined,components.OpSoft?{OpSoft:components.OpSoft.FixedPrice}:undefined,components.FlashMedia?{FlashMedia:components.FlashMedia.FixedPrice}:undefined,components.IPv?{IPv:components.IPv.FixedPrice}:undefined);allPrices=Object.values(allPrices).filter((item=>item));totalPrice=utilGlobal.calculateServerPrice(allPrices);allPricesArray.push(totalPrice)}const isGbps=components.PortSpeed.Value>=1e3;const formattedPortSpeed=isGbps?`${components.PortSpeed.Value/1e3} Gbps`:`${components.PortSpeed.Value} Mbps`;tableBodyHtml+=`\n \n \n \n \n \n\n \n ${components.CPU.Value>1?`${components.CPU.Value} x`:""} ${components.CPU.SubItem}\n \n | \n \n ${components.GPU?`\n \n \n \n \n \n \n ${components.GPU.Value}\n \n | \n `:""}\n \n ${components.OS?`\n \n \n \n \n \n \n ${components.OS.Value}\n \n | \n `:""}\n \n ${components.IPv?`\n \n \n \n \n \n \n ${components.IPv.Value} x ${components.IPv.SubItem}\n \n | \n `:""}\n \n ${components.OpSoft?`\n \n \n \n \n \n \n ${components.OpSoft.Value}\n \n | \n `:""}\n \n ${components.FlashMedia?`\n \n \n \n \n \n \n ${components.FlashMedia.Value}\n \n | \n `:""}\n\n \n \n\n \n\n ${components.RAM.Value} GB\n | \n\n \n \n \n \n\n \n ${hddAvailable===1?"":`${hddAvailable} x`} ${components.HDD.SubItem}\n \n | \n\n \n \n \n \n\n ${formattedPortSpeed}\n | \n\n \n $ ${totalPrice.toFixed(2)}\n | \n\n \n \n \n \n \n\n CONFIGURE\n \n | \n
\n `}));const placeholderHtml=`\n \n \n Servers not found \n | \n
\n `;if(table){table.innerHTML=serversArray.length?tableBodyHtml:placeholderHtml}const cheapestPrice=document.getElementById("cheapest-server-price");if(cheapestPrice){cheapestPrice.innerText=Math.min(...allPricesArray)}}const setFiltersToDefault=()=>{const filterElement=document.querySelectorAll(".servers-filter .filter");filterElement.forEach((item=>{const filterType=item.dataset.type;if(filterType==="type"){const defaultInput=item.querySelector('form input[value="all"]');const allInputs=item.querySelectorAll("form input");allInputs.forEach((input=>{input.checked=false}));defaultInput.checked=true}if(filterType==="deployment"){const defaultInput=item.querySelector('form input[value="instant"]');const allInputs=item.querySelectorAll("form input");allInputs.forEach((input=>{input.checked=false}));defaultInput.checked=true}if(filterType==="location"){const selectButton=item.querySelector("span.sBtn-text");if(selectButton){selectButton.innerHTML="Select your option"}}if(filterType==="hardware"){const hardwareFilters=item.querySelectorAll(".filter");hardwareFilters.forEach((hardwareItem=>{const selectButton=hardwareItem.querySelector("span.sBtn-text");if(selectButton){selectButton.innerHTML="Select your option"}}))}}))};const updateFilters=(data,deplyment,filterLocation)=>{if(deplyment==="instant"){const serverOptions=document.querySelectorAll(".servers-filter .select-menu .options");serverOptions.forEach((item=>{const type=item.dataset.target;if(["cpu","gpu","hdd","os","traffic","ram"].includes(type)){const list=dataModelGlobal.getListOfComponents(type,data);const locationList=dataModelGlobal.getListOfComponents("location",data);const availableLocationsElement=document.querySelector('.filter[data-type="location"] ul');if(list.length>0){let html=` \n \n \n Select your option\n \n `;list.forEach((component=>{let componentValue=component;if(type==="ram"){componentValue=`${component} GB`}html+=` \n \n \n ${componentValue}\n \n `}));item.innerHTML=html}if(!filterLocation&&locationList.length>0){let html=`\n \n \n Select your option\n \n `;locationList.forEach((component=>{const src=component==="Bucharest, EU"?"../../../images/flags/ro.svg":component==="Amsterdam, EU"?"../../../images/flags/nl.svg":"../../../images/flags/us.svg";const alt=component==="Bucharest, EU"?"Romania":component==="Amsterdam, EU"?"Netherlands":"US";html+=`\n \n \n ${component}\n \n `}));availableLocationsElement.innerHTML=html}}}));const mobilePricingWrapper=document.querySelector(".filter-pricing-wrapper.mobile");const desktopPricingWrapper=document.querySelector(".filter-pricing-wrapper.desktop");const initialServersFilters=dataModelGlobal.getServersFilters();if(mobilePricingWrapper){const{pricing:pricing}=initialServersFilters;const minRangeElement=mobilePricingWrapper.querySelector("span.range1");const maxRangeElement=mobilePricingWrapper.querySelector("span.range2");const sliderOne=mobilePricingWrapper.querySelector("input.slider-1");const sliderTwo=mobilePricingWrapper.querySelector("input.slider-2");if(minRangeElement){minRangeElement.innerHTML=parseInt(pricing.minPrice).toString()}if(maxRangeElement){maxRangeElement.innerHTML=parseInt(pricing.maxPrice).toString()}if(sliderOne){sliderOne.min=parseInt(pricing.minPrice).toString();sliderOne.max=parseInt(pricing.maxPrice).toString();sliderOne.value=parseInt(pricing.minPrice).toString()}if(sliderTwo){sliderTwo.min=parseInt(pricing.minPrice).toString();sliderTwo.max=parseInt(pricing.maxPrice).toString();sliderTwo.value=parseInt(pricing.maxPrice).toString()}}if(desktopPricingWrapper){const{pricing:pricing}=initialServersFilters;const minRangeElement=desktopPricingWrapper.querySelector("span.range1");const maxRangeElement=desktopPricingWrapper.querySelector("span.range2");const sliderOne=desktopPricingWrapper.querySelector("input.slider-1");const sliderTwo=desktopPricingWrapper.querySelector("input.slider-2");if(minRangeElement){minRangeElement.innerHTML=parseInt(pricing.minPrice).toString()}if(maxRangeElement){maxRangeElement.innerHTML=parseInt(pricing.maxPrice).toString()}if(sliderOne){sliderOne.min=parseInt(pricing.minPrice).toString();sliderOne.max=parseInt(pricing.maxPrice).toString();sliderOne.value=parseInt(pricing.minPrice).toString()}if(sliderTwo){sliderTwo.min=parseInt(pricing.minPrice).toString();sliderTwo.max=parseInt(pricing.maxPrice).toString();sliderTwo.value=parseInt(pricing.maxPrice).toString()}}const selectButton=document.querySelectorAll(".select-btn span");if(selectButton){selectButton.forEach((item=>{const target=item.dataset.target;if(target==="location"){item.innerHTML=initialServersFilters.location?initialServersFilters.location:"Select your option"}else if(["cpu","gpu","ram","hdd","os","traffic"].includes(target)){item.innerHTML=initialServersFilters.hardware[target]?initialServersFilters.hardware[target]:"Select your option"}}))}}};const demo=(serverData,filtersData)=>{let filteredData=serverData;Object.entries(filtersData).forEach((filter=>{const key=filter[0];const value=filter[1];if(value===null){return}if(["type","deployment"].includes(key)){return}if(key==="location"){filteredData=serverData.filter((item=>item[key]===value))}if(key==="hardware"){Object.entries(value).forEach((item=>{const hardwareKey=item[0];const hardwareValue=item[1];if(hardwareValue===null){return}filteredData=filteredData.filter((arrItem=>{const prettyvalue=hardwareKey==="ram"?hardwareValue.split(" ")[0]:hardwareValue;const prettykey=hardwareKey==="ram"?arrItem[hardwareKey].toString():arrItem[hardwareKey];return prettykey===prettyvalue.toString()}))}))}if(key==="pricing"){const{pricing:pricing}=filtersData;const{minPrice:minPrice,maxPrice:maxPrice}=pricing;filteredData=filteredData.filter((item=>parseInt(item.price)>=minPrice&&parseInt(item.price)<=maxPrice))}}));return filteredData};const updateRadioFilters=()=>{const initialServerFilters=dataModelGlobal.getServersFilters();const inputRadio=document.querySelectorAll('input[type="radio"]');removeFilter();if(inputRadio){inputRadio.forEach((item=>{if(item.name==="type"&&item.value===initialServerFilters.type){item.checked=true}else if(item.name==="deployment"&&item.value===initialServerFilters.deployment){item.checked=true}}))}};const removeFilter=()=>{const url=window.location.pathname;const typeFilter=document.querySelector(`.filter[data-type="type"]`);const deploymentFilter=document.querySelector(`.filter[data-type="deployment"]`);const fiveBareMetalFilter=document.querySelector(".filter form .five-bare-metal");if(["/web3/","/vmware/","/transcoding/","/rtx30/","/nvme/","/artificial-intelligence/","/machine-learning/","/llm/","/l40s/","/instinct/","/h100/","/dedicated/nvme/","/dedicated/gpu/pricing/","/dedicated/entry/pricing/"].includes(url)){if(typeFilter){typeFilter.remove()}}if(["/deals/"].includes(url)){if(deploymentFilter){deploymentFilter.remove()}if(fiveBareMetalFilter){fiveBareMetalFilter.remove()}}};async function renderServers(params){const{target:target,norender:norender}=params;const data=await eventsGlobal.formatServerData();const url=window.location.pathname;if(!norender){dataModelGlobal.setInitialPriceingFilters(data)}const initialServerFilters=dataModelGlobal.getServersFilters();const{deployment:deployment,cpu:cpu,location:location,pricing:pricing,type:type,hardware:hardware}=initialServerFilters;const filteredData=deployment==="instant"?demo(data,initialServerFilters):data;if(!norender){updateFilters(data,deployment,location,true)}updateRadioFilters();const filterElement=document.querySelectorAll(".servers-filter .filter");const hasServers=target.children.length>1;if(hasServers){Array.from(target.children).forEach((item=>{item.remove()}))}filterElement.forEach((item=>{item.classList.remove("d-none")}));if(deployment==="custom"){filterElement.forEach((item=>{const type=item.dataset.type;if(["location","cpu","gpu","os","ram","hdd","traffic","hardware","pricing"].includes(type)){item.classList.add("d-none")}}))}const sortedServers=filteredData.toSorted(((a,b)=>a.price-b.price));const duplicatesArray=dataModelGlobal.groupDuplicatesV2(sortedServers);let id=1;const sortedDuplicatesArray=[];Object.entries(duplicatesArray).forEach((item=>{if(item[1].length>1){item[1].forEach(((duplicate,index)=>{const editedDuplicate=index===0?{...duplicate,duplicate:id,showDuplicate:true}:{...duplicate,duplicate:id,showDuplicate:false};sortedDuplicatesArray.push(editedDuplicate)}));id+=1}else{item[1].forEach((notDuplicate=>{sortedDuplicatesArray.push(notDuplicate)}))}}));if(!target){console.error("Target container not found");return}let html="";if(!sortedDuplicatesArray||sortedDuplicatesArray.length===0){html+=`\n \n
\n
Servers not found
\n
\n `}else{sortedDuplicatesArray.forEach((item=>{const{cpu:cpu,gpu:gpu,hdd:hdd,location:location,name:name,os:os,ram:ram,traffic:traffic,type:type}=item;const isHiddenDuplicate=Object.hasOwn(item,"duplicate")&&Object.hasOwn(item,"showDuplicate")&&item.showDuplicate===false;const isVisibleDuplicate=Object.hasOwn(item,"duplicate")&&Object.hasOwn(item,"showDuplicate")&&item.showDuplicate===true;const duplicateNumber=Object.hasOwn(item,"duplicate")?item.duplicate:null;const customLocation=item.Location;const{preselectGPU:preselectGPU,GPUid:GPUid,preselectBandwidth:preselectBandwidth,preselectStreaming:preselectStreaming,FlashMediaID:FlashMediaID,PortSpeedID:PortSpeedID}=item;const preselectComponents=[{name:"preselectGPU",value:preselectGPU,id:GPUid},{name:"preselectBandwidth",value:preselectBandwidth,id:PortSpeedID},{name:"preselectStreaming",value:preselectStreaming,id:FlashMediaID}];let preselectText="";preselectComponents.forEach((preselectItem=>{if(!preselectItem.value){return}preselectText+=`&${preselectItem.name}=${preselectItem.id}`}));const hrefLink=preselectText===""?utilGlobal.changeOrderLink(type,name):utilGlobal.changeOrderLink(type,name,preselectText);const initialPrice=item.price;const discountPercent=item&&item.discount&&item.discount.percent;const discountPrice=item&&item.discount&&item.discount.price;let currency="$";if(Object.hasOwn(item,"location")){currency=item.location.includes("US")?"$":"€"}const monthlyHtml=`\n ${discountPercent&&discountPrice?`${currency}${initialPrice.toFixed(2)}`:""}\n `;const discountItem=`\n ${discountPercent&&discountPrice?`-${discountPercent}%
`:""}\n `;const calculatedPrice=discountPercent&&discountPrice?discountPrice:initialPrice;const gpuItem=`\n ${gpu?`\n `:""}\n `;let city=undefined;if(location){const citySplitArray=location.split(",");city=citySplitArray.length?citySplitArray[0].trim():"Bucharest"}const locationData={Bucharest:{src:"ro.svg",alt:"Bucharest"},Amsterdam:{src:"nl.svg",alt:"Amsterdam"},"New York":{src:"us.svg",alt:"New York"},Miami:{src:"us.svg",alt:"Miami"},"San Francisco":{src:"us.svg",alt:"San Francisco"}};let orderBtnClassName=["order-button"];if(deployment==="instant"){orderBtnClassName.push("instant-btn")}else{if(Website.includes("serverroom.net")){orderBtnClassName.push("custom-sr-btn")}else{orderBtnClassName.push("custom-pc-btn")}}orderBtnClassName=orderBtnClassName.join(" ");html+=`\n \n
\n
\n
${cpu}
\n ${discountItem}\n
\n \n
\n
\n \n
\n `;if(os){html+=`\n
\n `}html+=` \n
\n
${traffic}
\n
Bandwidth
\n
\n `;if(url==="/dedicated/wowza/"){html+=`\n
\n
Wowza License & Management
\n
Streaming Solution
\n
\n `}if(url==="/dedicated/xtream/"){html+=`\n
\n
Xtream Codes Support and Management
\n
Streaming Solution
\n
\n `}if(url==="/dedicated/red5/"){html+=`\n
\n
Red5
\n
Streaming Solution
\n
\n `}html+=`\n ${gpuItem}\n
\n `;if(location){html+=` \n
\n
\n\n
${location}
\n
\n `}if(customLocation){html+='
';customLocation.forEach((item=>{const citySplitArray=item.Value.split(",");const city=citySplitArray.length?citySplitArray[0].trim():"Bucharest";html+=`\n
\n
\n\n
${item.Value}
\n
\n `}));html+="
"}html+=` \n
\n \n
\n
\n `}))}target.innerHTML=html}function initRenderCustomTable(data,tableID,componentsArr,extraData=undefined){const tableHeaderCustom=document.querySelector(`${tableID} .table-configuration-header`);const tableBodyCustom=document.querySelector(`${tableID} .table-configuration-body`);uiGlobal.renderTableHeader(undefined,tableHeaderCustom,componentsArr);uiGlobal.renderCustomTable(data,tableBodyCustom,componentsArr,extraData)}function toggleLoader(action){const loader=document.querySelector(".loader");const footer=document.getElementById("main-footer");const prevElement=loader&&loader.previousElementSibling;if(loader&&footer&&prevElement){switch(action){case"show":prevElement.classList.add("d-none");prevElement.classList.remove("d-flex");prevElement.classList.remove("mx-auto");loader.classList.remove("d-none");footer.classList.remove("mt-auto");break;case"hide":prevElement.classList.add("d-flex");prevElement.classList.remove("d-none");prevElement.classList.add("mx-auto");loader.classList.add("d-none");footer.classList.add("mt-auto");break}}}const globalSwal=window.Swal?Swal.mixin({customClass:{confirmButton:"btn btn-success",cancelButton:"btn btn-danger",denyButton:"btn btn-secondary"},buttonsStyling:false,reverseButtons:true}):undefined;const globalToast=window.Swal?Swal.mixin({toast:true,showConfirmButton:false,timer:4500,timerProgressBar:false}):undefined;function showGlobalSwalError(text,reload){toggleLoader("show");if(reload){globalSwal.fire({title:text,icon:"error",showConfirmButton:false,showCancelButton:false,showCloseButton:false,allowOutsideClick:true,footer:'Go Back to the previous order step'})}else{globalSwal.fire({title:text,icon:"error",showConfirmButton:false,showCancelButton:false,showCloseButton:false,allowOutsideClick:true})}}function showGlobalSwalSuccess(text){toggleLoader("show");globalSwal.fire({title:text,icon:"success",showConfirmButton:true,showCancelButton:false,showCloseButton:false,allowOutsideClick:true})}function renderAvatarProfileMenu(){const userProfileAvatarContainer=document.querySelectorAll(".user-profile-avatar");const uiAvatarImage=document.querySelectorAll(".avatar-image");const uiAccountID=document.querySelectorAll(".aid .value");const uiFullName=document.querySelectorAll(".full-name");const uiEmail=document.querySelectorAll(".email");const uiAccountName=document.querySelectorAll(".account-name");const uiViewProfileRedirect=document.querySelectorAll(".view-profile-btn");const uiSettingsRedirect=document.querySelectorAll(".settings-redirect");const itemsDoesNotExist=[uiAvatarImage.length,uiAccountID.length,uiFullName.length,uiEmail.length,uiAccountName.length,uiViewProfileRedirect.length,uiSettingsRedirect.length].some((item=>!item));const localStorageKeys={userInfoLoginData:"userInfoLoginData"};const userInfoLoginData=JSON.parse(localStorage.getItem(localStorageKeys.userInfoLoginData));if(itemsDoesNotExist){return}if(!userInfoLoginData){if(userProfileAvatarContainer.length){userProfileAvatarContainer.forEach((item=>item.remove()))}return}const invalidData=Object.values(userInfoLoginData).some((item=>!item));if(invalidData){console.error("Invalid userInfoLoginData! You have to login");return}const{LastName:LastName,FirstName:FirstName,SelectedAid:SelectedAid,Email:Email,AccountName:AccountName}=userInfoLoginData;const redirectLink=`/new-control-panel/settings/#${SelectedAid}`;uiAvatarImage.forEach((item=>item.textContent=`${FirstName[0]}${LastName[0]}`));uiAccountID.forEach((item=>item.textContent=SelectedAid));uiFullName.forEach((item=>item.textContent=`${FirstName} ${LastName}`));uiEmail.forEach((item=>item.textContent=Email));uiAccountName.forEach((item=>item.textContent=AccountName));uiViewProfileRedirect.forEach((item=>item.href=redirectLink));uiSettingsRedirect.forEach((item=>item.href=redirectLink))}return{renderTableHeader:renderTableHeader,renderCustomTable:renderCustomTable,renderServers:renderServers,initRenderCustomTable:initRenderCustomTable,toggleLoader:toggleLoader,globalSwal:globalSwal,globalToast:globalToast,showGlobalSwalError:showGlobalSwalError,showGlobalSwalSuccess:showGlobalSwalSuccess,renderCheapestServerPrice:renderCheapestServerPrice,findParent:findParent,renderAvatarProfileMenu:renderAvatarProfileMenu,setFiltersToDefault:setFiltersToDefault,removeFilter:removeFilter}}();