(function(){"use strict";function init(){alertCookieExists()||getLocation()}function getLocation(){let data=getSessionData();data?(debug&&console.log("Data from session exists: ",data),processLocation(data.country,data.langs)):(debug&&console.log("No session data, so calling IP locator..."),data=processCloudflareLocation())}function processCloudflareLocation(){getCloudflareData(function(err,data){if(err!==null)return console.log(err),"";else{let l=navigator.languages;l===undefined&&(l=[],l.push(navigator.language));const arr=data.trim().split("\n");for(let i=0;i<data.length;i++){const entry=arr[i];if(entry&&entry.startsWith("loc=")){let match=entry.substring(4,6);processLocation(match,l);storeSessionData({country:match,langs:l});return}}}})}function processLocation(country,languages){const alertElem=document.getElementById("geo-location-alert");if(!alertElem){debug&&console.log("The alert HTML is not present");return}const currentLang=document.getElementsByTagName("html")[0].getAttribute("lang");let foundLang="";if(country)if(foundLang=locMap[country],foundLang){if(foundLang.toLowerCase()===currentLang.toLowerCase()){debug&&console.log(foundLang+" is the same as current lang");return}}else foundLang="";languages||(languages=[]);const messageElem=document.getElementById("js-switch-message"),linkElem=document.getElementById("geo-location-selected"),alertCloseElem=document.getElementById("js-switch-close"),pageId=document.getElementsByTagName("body")[0].getAttribute("data-id"),job=document.getElementById("js-job-identifier");let jobId=null;job&&(jobId=job.getAttribute("content"));getSuggestedPage(pageId,country,foundLang,languages.join(","),jobId,function(err,data){if(err!==null)return console.log(err),null;else{debug&&console.log(data);const fields=data.cultureUrl;messageElem.innerHTML=data.messageText;linkElem.setAttribute("href",fields.url);alertElem.setAttribute("lang",fields.culture);alertElem.classList.add("show");alertElem.removeAttribute("hidden");linkElem.addEventListener("click",function(){setAlertCookie(fields.Culture,90)});alertCloseElem.addEventListener("click",function(){setAlertCookie("close",7)})}})}function getCloudflareData(callback){const xhr=new XMLHttpRequest;xhr.open("GET","https://www.cloudflare.com/cdn-cgi/trace",!0);xhr.responseType="text";xhr.onload=function(){const status=xhr.status;status===200?callback(null,xhr.response):callback(status,xhr.response)};xhr.send()}function getSuggestedPage(id,country,siteCodes,langCodes,jobId,callback){const url="/Umbraco/language/Detection/GetSuggestedSiteData?id="+id+"&countryCode="+country+"&siteCodes="+siteCodes+"&languageCodes="+langCodes+"&jobId="+jobId,xhr=new XMLHttpRequest;xhr.open("GET",url,!0);xhr.responseType="json";xhr.setRequestHeader("x-ph","internal");xhr.onload=function(){const status=xhr.status;status===200?callback(null,xhr.response):callback(status,xhr.response)};xhr.send()}function alertCookieExists(){return Cookies.get(alertCookieName)}function setAlertCookie(value,days){debug&&console.log("Cookie: ",value,days);Cookies.set(alertCookieName,value,{expires:days,sameSite:"strict",secure:!0})}function getSessionData(){const data=sessionStorage.getItem(sessionKey);return data?JSON.parse(data):null}function storeSessionData(data){const json=JSON.stringify(data);sessionStorage.setItem(sessionKey,json)}String.prototype.startsWith||(String.prototype.startsWith=function(searchString,position){return position=position||0,this.indexOf(searchString,position)===position});const debug=!1,alertCookieName="ph_setLang",sessionKey="ph.countryLang",locMap={GB:"en",US:"en",CA:"en",AU:"en",IE:"en",IM:"en",JE:"en",MT:"en",NZ:"en",UM:"en",ZA:"en",GG:"en",JM:"en",MS:"en",VG:"en",VI:"en",BS:"en",BB:"en",TT:"en",GI:"en",SV:"SV",ES:"es",PA:"es",AR:"es",CL:"es",CU:"es",MX:"es",GT:"es",PH:"en",FR:"fr",PT:"pt",DE:"de",IT:"it",NL:"nl",JA:"ja",KO:"ko",TH:"th"};init()})();
//# sourceMappingURL=/phb/nmap/origin.js.v39e3612af5ec0b70db65649470c087dbd23d812e