window.addEventListener("load",function(){function t(t){var e=t.closest(".directorist-search-field");e&&!e.hasClass("input-is-focused")&&e.addClass("input-is-focused")}var e;e=jQuery,setTimeout(function(){if("google"===directorist.i18n_text.select_listing_map){o=function(t){var o=t.target.closest(".directorist-search-field").querySelector(".location-name"),i=t.target.closest(".directorist-search-field").querySelector("#cityLat"),a=t.target.closest(".directorist-search-field").querySelector("#cityLng");navigator.geolocation?navigator.geolocation.getCurrentPosition(function(t){lat=t.coords.latitude,lon=t.coords.longitude,function(t,i){var a;a=new google.maps.Geocoder;var n=new google.maps.LatLng(t,i);a.geocode({latLng:n},function(t,i){if(i==google.maps.GeocoderStatus.OK)if(t[0]){var a=function(t){if(!t||!t.address_components)return"";var e=t.address_components;return e.length>0&&e[0].long_name&&e[0].long_name.includes("+")&&(e=e.slice(1)),e.map(function(t){return t.long_name}).join(", ")}(t[0]).split(",");count=a.length,country=a[count-1],state=a[count-2],city=a[count-3],o.value=a,e(".directorist-location-js, .atbdp-search-address").attr("data-value",city)}else o.value="address not found";else o.value="Geocoder failed due to: ".concat(i)})}(lat,lon),i.value=lat,a.value=lon},function(t){switch(t.code){case t.PERMISSION_DENIED:o.value="User denied the request for Geolocation.";break;case t.POSITION_UNAVAILABLE:o.value="Location information is unavailable.";break;case t.TIMEOUT:o.value="The request to get user location timed out.";break;case t.UNKNOWN_ERROR:o.value="An unknown error occurred."}}):o.value="Geolocation is not supported by this browser.";var n=t.target.closest(".directorist-search-field");n&&!n.classList.contains("input-is-focused")&&n.classList.add("input-is-focused")},document.body.addEventListener("click",function(t){document.querySelectorAll(".directorist-filter-location-icon > i, .directorist-filter-location-icon > span").forEach(function(e){t.target===e&&o(t)})})}else"openstreet"===directorist.i18n_text.select_listing_map&&e("body").on("click",".directorist-filter-location-icon",function(o){navigator.geolocation.getCurrentPosition(function(i){return function(o,i){var a=o.coords.latitude,n=o.coords.longitude;i.target,e.ajax({url:"https://nominatim.openstreetmap.org/reverse?format=json&lon=".concat(n,"&lat=").concat(a),type:"GET",data:{},success:function(o){e(".directorist-location-js, .atbdp-search-address").val(o.display_name),e(".directorist-location-js, .atbdp-search-address").attr("data-value",o.display_name),e("#cityLat").val(a),e("#cityLng").val(n),t(e(".directorist-location-js"))},error:function(o){e(".directorist-location-js").val("Location not found"),t(e(".directorist-location-js"))}})}(i,o)})});var o},1e3)});