var FPFramework_GeoIP_Lookup=function(){function e(){this.handleLookup()}var n=e.prototype;return n.handleLookup=function(){var u=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 i=e.target,c=e.target.innerHTML;i.classList.remove("btn-danger"),i.innerHTML=fpf_js_object.FPF_LOADING,i.classList.add("btn-working"),fetch(fpf_js_object.ajax_url,{method:"POST",body:r}).then(function(e){return u.emptyResults(),e.json()}).then(function(e){var n=document.querySelector(".fpf-geoip-lookup-results");if(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);var t=e.subdivisions&&e.subdivisions.length?e.subdivisions[e.subdivisions.length-1]:null;t&&(n.querySelector(".region").innerHTML=t.names&&t.names.en||t.name||""),n.style.display="block"}else alert(fpf_js_object.FPF_INVALID_IP_ADDRESS),n.style.display="none"}).finally(function(){i.innerHTML=c,i.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.querySelector(".region").innerHTML=""},e}();document.addEventListener("DOMContentLoaded",function(e){new FPFramework_GeoIP_Lookup});

