var FPFramework_GeoIP_Lookup=function(){function e(){this.handleLookup()}var n=e.prototype;return n.handleLookup=function(){var i=this;document.querySelector(".GeoIpLookupButton").addEventListener("click",function(e){var n=e.target.closest(".fpf-geo-lookup-wrapper"),t=n.querySelector('input[type="hidden"].nonce_hidden').value,o=n.querySelector(".geoip-ip-address").value;if(!o)return alert(fpf_js_object.FPF_ENTER_VALID_IP_ADDRESS),!1;var r=new FormData;r.append("nonce",t),r.append("action","fpf_on_geoip_ajax"),r.append("task","get"),r.append("ip",""+o);var c=e.target,u=e.target.innerHTML;c.classList.remove("btn-danger"),c.innerHTML=fpf_js_object.FPF_LOADING,c.classList.add("btn-working"),fetch(fpf_js_object.ajax_url,{method:"POST",body:r}).then(function(e){return i.emptyResults(),e.json()}).then(function(e){var n=document.querySelector(".fpf-geoip-lookup-results");e?(e.continent&&(n.querySelector(".continent").innerHTML=e.continent.names.en),e.city&&(n.querySelector(".city").innerHTML=e.city.names.en),e.country&&(n.querySelector(".country").innerHTML=e.country.names.en,n.querySelector(".country_code").innerHTML=e.country.iso_code),n.style.display="block"):(alert(fpf_js_object.FPF_INVALID_IP_ADDRESS),n.style.display="none")}).finally(function(){c.innerHTML=u,c.classList.remove("btn-working")}),e.preventDefault()})},n.emptyResults=function(){var e=document.querySelector(".fpf-geoip-lookup-results");e.querySelector(".continent").innerHTML="",e.querySelector(".city").innerHTML="",e.querySelector(".country").innerHTML="",e.querySelector(".country_code").innerHTML=""},e}();document.addEventListener("DOMContentLoaded",function(e){new FPFramework_GeoIP_Lookup});

