PageSourceSearch

https://domicil.global/wp-content/cache/min/1/9f0845aa8946/wp-cont…/js/wplf-public-domicil.js?ver=1790902783

js domicil.global collected 2026-10-10 01:02:26 UTC 79,470 bytes, 327 lines download raw bytes

1(function($){'use strict';if(typeof wplf_params==='undefined'){return}
2var wplfMaps={};var markers={};var wplfMarkerClusterer={};var wplfOpenMapInstances={};var mapId=wplf_params.map_id;var panorama;var userLat=-33.8688;var userLng=151.2195;var osmLat='',osmLng='';var open_detail_new_tab=wplf_params.open_detail_new_tab;var map_provider=wplf_params.map_provider;var google_map_type=wplf_params.google_map_type;var google_map_layer=wplf_params.google_map_layer;var google_map_layer_url=wplf_params.google_map_layer_url;var osm_map_type=wplf_params.osm_map_type;var osm_custom_tile=wplf_params.osm_custom_tile;var wplfRouteControl={};var directionsService={},directionsRenderer={};var wplfGeolocation=!0;var dlx=window.dlx_params||{};var dlxSearchCountry={};var dlxCountryActive={};var dlxSearchIsCountry={};var dlxFitMode={};function dlxCountryFromComponents(components){if(!components||!components.length)return'';for(var i=0;i<components.length;i++){if(components[i].types&&components[i].types.indexOf('country')!==-1){return(components[i].short_name||'').toUpperCase()}}
3return''}
4function dlxEsc(str){return String(str).replace(/[&<>"']/g,function(c){return{'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'}[c]})}
5function dlxCtaHtml(location,style){if(!location.local_url)return'';var label=dlxEsc(location.local_label||'');var url=dlxEsc(location.local_url);var icon=dlx.icon?'<img src="'+dlxEsc(dlx.icon)+'" alt="">':'';if(style==='popup'){return'<a class="wplf-details-icon wplf-dlx-cta" href="'+url+'" target="_blank" rel="noopener">'+icon+'<span>'+label+'</span></a>'}
6return'<a class="wplf-dlx-cta-btn wplf-action-btn" href="'+url+'" target="_blank" rel="noopener">'+icon+' '+label+'</a>'}
7function dlxRank(loc){var r=parseInt(loc.store_rank,10);return isNaN(r)?999:r}
8var show_marker_description=wplf_params.show_marker_description;var show_result_list_description=wplf_params.show_result_list_description;var wplfSubmissionMaps={};var wplfSubmissionMarkers={};var distance_unit=wplf_params.distance_unit;var currentRequestSuggestion=null;function getOsmTileLayer(layerType){var layer=null;var osmTileProviders={default:{url:'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',attribution:'© OpenStreetMap contributors'},hot:{url:'https://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png',attribution:'© OpenStreetMap contributors, Humanitarian OpenStreetMap Team'},opentopo:{url:'https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png',attribution:'© OpenStreetMap, SRTM | © OpenTopoMap (CC-BY-SA)'},carto_light:{url:'https://cartodb-basemaps-a.global.ssl.fastly.net/light_all/{z}/{x}/{y}{r}.png',attribution:'© OpenStreetMap contributors, © CARTO'},carto_dark:{url:'https://cartodb-basemaps-a.global.ssl.fastly.net/dark_all/{z}/{x}/{y}{r}.png',attribution:'© OpenStreetMap contributors, © CARTO'},esri_street:{url:'https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}',attribution:'Tiles © Esri'},esri_satellite:{url:'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}',attribution:'Tiles © Esri'}};if(layerType==='custom'&&osm_custom_tile!==''){try{layer=eval("("+osm_custom_tile+")")}catch(e){var provider=osmTileProviders['default'];layer=L.tileLayer(provider.url,{attribution:provider.attribution})}}else{var provider=osmTileProviders[layerType]||osmTileProviders['default'];layer=L.tileLayer(provider.url,{attribution:provider.attribution})}
9return layer}
10$('select.wplf-filter-select[id^="country-"]').each(function(){var $sel=$(this),$opts=$sel.find('option').filter(function(){return this.value!==''});$opts.sort(function(a,b){return a.text.localeCompare(b.text)}).appendTo($sel)});$('.wplf-filter-select').each(function(){this._dlxChoices=new Choices(this,{searchEnabled:!1,itemSelectText:'',shouldSort:!1})});if($('.wplf-single-map').length||$('.wplf-content').length||$('.wplf-submission-form').length){var lang='en';if($('html').prop('lang')){lang=$('html').prop('lang')}
11if(map_provider=='google'){$.ajax({type:'GET',url:wplf_params.ajax_url,data:{action:'wplf_get_settings'},success:function(res){const data=res.data;if(data){const key=data.api_key?data.api_key:'';mapId=data.map_id;const existingScript=$('#wplf-google-maps-script');if(existingScript.length){existingScript.remove()}
12const isWpfdWpBakery=typeof wpfdWpBakery!=='undefined'&&wpfdWpBakery===!0;
12const scriptUrl=isWpfdWpBakery?`https://maps.googleapis.com/maps/api/js?key=${key}&callback=initMap&libraries=places,marker&language=${lang}`:`https://maps.googleapis.com/maps/api/js?key=${key}&callback=initMap&loading=async&libraries=places,marker&language=${lang}`;const script=$('<script>',{src:scriptUrl,id:'wplf-google-maps-script',async:!0,defer:!0});$('head').append(script)}else{alert(wplf_translate.msg_set_google_api_key)}}})}else{if($('.wplf-single-map').length){if(navigator.geolocation){navigator.geolocation.getCurrentPosition(function(position){userLat=position.coords.latitude;userLng=position.coords.longitude;initSingleOpenStreetMaps(userLat,userLng)},function(error){initSingleOpenStreetMaps(userLat,userLng)})}else{initSingleOpenStreetMaps(userLat,userLng)}}
13if($('.wplf-content').length){initWplfMaps()}
14if($('.wplf-submission-form').length){initWplfSubmissionMaps()}}}
15function initSingleOpenStreetMaps(userLat,userLng){var maps=$('.wplf-single-map');maps.each(function(){var locationId=$(this).data('id');var lat=$(this).data('lat');var lng=$(this).data('lng');var markerIcon=$(this).data('marker');var isDefaultMarker=$(this).data('isdefaultmarker');var isGoogleIcon=$(this).data('isgoogleicon');var singleMapZoom=$(this).data('zoom');var singleImg=$(this).data('img');var singleName=$(this).data('name');var singleAddress=$(this).data('address');var singleContact=$(this).data('contact');wplfSetMapHeight(locationId);$(window).resize(function(){wplfSetMapHeight(locationId)});let markerContent;if(markerIcon.startsWith("<svg")){const parser=new DOMParser();const pinSvgString=markerIcon;markerContent=parser.parseFromString(pinSvgString,"image/svg+xml").documentElement}else{markerContent=document.createElement("img");markerContent.src=markerIcon;markerContent.width=40;markerContent.height=40}
16var customIcon=L.divIcon({className:"custom-marker",html:markerContent,iconSize:[40,40]});var popupContent=`
17		        <div class="wplf-map-marker">
18				    <div class="wplf-map-marker-close" onclick="wplfClosePopup('${locationId}', true)">
19				        <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
20							<path d="M8.4 17L7 15.6L10.6 12L7 8.42502L8.4 7.02502L12 10.625L15.575 7.02502L16.975 8.42502L13.375 12L16.975 15.6L15.575 17L12 13.4L8.4 17Z" fill="white"></path>
21						</svg>
22				    </div>
23				    <div class="wplf-map-marker-header">
24				        <div class="wplf-map-marker-image"><img src="${singleImg}"></div>
25				    </div>
26				    <div class="wplf-map-marker-body">
27					    <div class="wplf-map-marker-content">
28					    	<span class="wplf-map-marker-title">${singleName}</span>
29					        <span class="wplf-map-marker-address">${singleAddress}</span>
30					    </div>
31					    <div class="wplf-map-marker-footer">
32                            <a class="wplf-details-icon" id="wplf-route-btn" href="https://www.google.com/maps/dir/?api=1&origin=${userLat},${userLng}&destination=${lat},${lng}" target="_blank">
33                                <img src="${wplf_params.icon_route}" alt="${wplf_translate.route}">
34                                <span>${wplf_translate.route}</span>
35                            </a>
36                            <a class="wplf-details-icon" id="wplf-street-view-btn" href="https://www.google.com/maps/place/${lat},${lng}" target="_blank">
37                                <img src="${wplf_params.icon_street}" alt="${wplf_translate.street_view}">
38                                <span>${wplf_translate.street_view}</span>
39                            </a>
40					    </div>
41				    </div>
42				</div>
43		    `;var singleMapId='wplf-map-'+locationId;var singleMap=L.map(singleMapId).setView([lat,lng],singleMapZoom);var tileLayer=getOsmTileLayer(osm_map_type);tileLayer.addTo(singleMap);tileLayer.on('tileerror',function(){singleMap.removeLayer(tileLayer);getOsmTileLayer('default').addTo(singleMap)});wplfOpenMapInstances[locationId]=singleMap;var marker=L.marker([lat,lng],{icon:customIcon}).addTo(singleMap);marker.bindPopup(popupContent)})}
44window.wplfClosePopup=function(locationId,isSingleLocation){if(isSingleLocation){var mapObject=wplfOpenMapInstances[locationId]}else{var mapObject=wplfMaps[locationId]}
45if(mapObject){mapObject.closePopup()}}
46window.initMap=function(){if($('.wplf-content').length){initWplfMaps()}
47if($('.wplf-single-map').length){if(map_provider=='google'){initSingleMaps(userLat,userLng);if(navigator.geolocation){navigator.geolocation.getCurrentPosition(function(position){userLat=position.coords.latitude;userLng=position.coords.longitude;initSingleMaps(userLat,userLng)},function(error){initSingleMaps(userLat,userLng)})}else{initSingleMaps(userLat,userLng)}}else{if(navigator.geolocation){navigator.geolocation.getCurrentPosition(function(position){userLat=position.coords.latitude;userLng=position.coords.longitude;initSingleOpenStreetMaps(userLat,userLng)},function(error){initSingleOpenStreetMaps(userLat,userLng)})}else{initSingleOpenStreetMaps(userLat,userLng)}}}
48if($('.wplf-submission-form').length){initWplfSubmissionMaps()}}
49function initWplfMaps(){$('.wplf-content').each(function(){var contentId=$(this).data('id');var map_zoom=parseInt($(this).find('#wplf-map_zoom-'+contentId).val());var default_address=$(this).find('#wplf-default_address-'+contentId).val();var searchButton=$(this).find('.wplf-search-btn');var geolocateButton=$(this).find('.wplf-geolocate-me');var addressInput=$(this).find('#address_search-'+contentId);var listMap=$('#list-map-'+contentId);var nameInput=$(this).find('#name_search-'+contentId);var nameSearchButton=$(this).find('.wplf-name-search-btn');var nameClearButton=$(this).find('.wplf-name-search-clear');if(map_provider=='google'){wplfMaps[contentId]=new google.maps.Map($('#wplf-map-'+contentId)[0],{center:{lat:userLat,lng:userLng},zoom:map_zoom,mapTypeControl:!1,streetViewControl:!1,rotateControl:!1,cameraControl:!1,zoomControl:!0,mapId:mapId,mapTypeId:google_map_type});switch(google_map_layer){case 'traffic':new google.maps.TrafficLayer().setMap(w
49plfMaps[contentId]);break;case 'transit':new google.maps.TransitLayer().setMap(wplfMaps[contentId]);break;case 'bicycling':new google.maps.BicyclingLayer().setMap(wplfMaps[contentId]);break;case 'kml':if(google_map_layer_url!==''){new google.maps.KmlLayer({url:google_map_layer_url,map:wplfMaps[contentId],preserveViewport:!0})}
50break}
51const geocoder=new google.maps.Geocoder();if($('#default_address').length>0){var input=$('#default_address')[0];var autocomplete=new google.maps.places.Autocomplete(input);autocomplete.setFields(['address_components','geometry']);autocomplete.addListener('place_changed',function(){var place=autocomplete.getPlace();var default_address=place.formatted_address||'';updateLocationShortcode();updateRightPanel()})}
52if(default_address!=''){geocoder.geocode({address:default_address},function(results,status){if(status==='OK'&&results[0]){var location=results[0].geometry.location;userLat=location.lat();userLng=location.lng();loadLocations(userLat,userLng,contentId);updateMapAndDistances(userLat,userLng)}else{console.error(wplf_translate.msg_geocoder_status+': '+status)}})}else if(navigator.geolocation){navigator.geolocation.getCurrentPosition(function(position){userLat=position.coords.latitude;userLng=position.coords.longitude
53const latLng=new google.maps.LatLng(userLat,userLng);geocoder.geocode({'location':latLng},function(results,status){if(status==='OK'&&results[0]){if(addressInput.length>0){addressInput.val(results[0].formatted_address);$('.wplf-form-search .btn-search-clear').removeClass('wplf-d-none')}}});loadLocations(userLat,userLng,contentId)},function(error){wplfGeolocation=!1;loadLocations(userLat,userLng,contentId)})}else{loadLocations(userLat,userLng,contentId)}}else{var mapId='wplf-map-'+contentId;if(wplfMaps[contentId]){wplfMaps[contentId].remove()}
54wplfMaps[contentId]=L.map(mapId).setView([userLat,userLng],map_zoom);wplfMaps[contentId].zoomControl.setPosition('topright');var tileLayer=getOsmTileLayer(osm_map_type);tileLayer.addTo(wplfMaps[contentId]);tileLayer.on('tileerror',function(){wplfMaps[contentId].removeLayer(tileLayer);getOsmTileLayer('default').addTo(wplfMaps[contentId])});observeMapResize(mapId,wplfMaps[contentId]);var locationiq_key=wplf_params.osm_api_key;var geocoderControlOptions={bounds:!1,markers:!1,attribution:null,expanded:!0,panToPoint:!1,params:{dedupe:1,}}
55if(default_address!=''){performOSMSearch(default_address,contentId,!1)}else if(navigator.geolocation){navigator.geolocation.getCurrentPosition(function(position){userLat=position.coords.latitude;userLng=position.coords.longitude;loadLocations(userLat,userLng,contentId)},function(error){loadLocations(userLat,userLng,contentId)})}else{loadLocations(userLat,userLng,contentId)}
56var geocoderControl=new L.control.geocoder(locationiq_key,geocoderControlOptions).addTo(wplfMaps[contentId]).on('select',function(e){$('#address_search-'+contentId).val(e.feature.feature.display_name);osmLat=e.latlng.lat;osmLng=e.latlng.lng}).on('error',function(error){if(error&&error.errorMessage&&error.errorCode==429){$.ajax({type:'POST',url:wplf_params.ajax_url,data:{action:'wplf_locationiq_limit_notice',wplf_nonce:wplf_params.nonce}})}});var searchBoxControl=$('#wplf-osm-search-box-'+contentId);var geocoderContainer=geocoderControl.getContainer();searchBoxControl.append(geocoderContainer);var iconSearchContent='<div class="btn-search-action wplf-leaflet-search"><img src="'+wplf_params.wplf_url+'public/icons/search-icon.svg" alt="search icon"></div>';searchBoxControl.find('.leaflet-locationiq-control').append(iconSearchContent);$('.wplf-osm-search-box .leaflet-locationiq-input').on('input',function(){$('#address_search-'+contentId).val($(this).val());searchBoxControl.find('.btn-search-action').css('right','35px');if($(this).val()==''){searchBoxControl.find('.btn-search-action').css('right','10px')}})
57searchBoxControl.find('.leaflet-locationiq-close').click(function(){searchBoxControl.find('.btn-search-action').css('right','10px');$('#address_search-'+contentId).val('');osmLat='';osmLng=''});searchBoxControl.find('.wplf-leaflet-search').click(function(){$(this).closest('.wplf-form-search').find('.btn-search').click()})
58$('.leaflet-locationiq-input').attr('placeholder',wplf_translate.placeholder_address)}
59if(addressInput.length>0){initializeAutocomplete(addressInput[0],contentId);addressInput.on('keydown',function(e){if(e.key==='Enter'){e.preventDefault();performSearch($(this),contentId)}})}
60if(nameSearchButton.length>0){$(nameSearchButton[0]).click(function(){performNameSearch(nameInput,contentId)})}
61if(nameClearButton.length>0){$(nameClearButton[0]).click(function(){nameInput.val('');$(this).addClass('wplf-d-none');$('#wplf-name-suggestions-'+contentId).addClass('wplf-d-none').html('');loadLocations(userLat,userLng,contentId)})}
62if(nameInput.length>0){nameInput.on('keydown',function(e){if(e.key==='Enter'){e.preventDefault();performNameSearch($(this),contentId)}});var suggestionTimer;nameInput.on('input',function(){var value=$(this).val();if(value.length>0){nameClearButton.removeClass('wplf-d-none')}else{nameClearButton.addClass('wplf-d-none')}
63clearTimeout(suggestionTimer);suggestionTimer=setTimeout(function(){fetchSuggestions(value,contentId)},300)});nameInput.on('focus click',function(){var value=$(this).val();if(value.length>0){nameClearButton.removeClass('wplf-d-none')}
64fetchSuggestions(value,contentId)});$(document).on('click',function(e){if(!$(e.target).closest('#name_search-'+contentId).length&&!$(e.target).closest('#wplf-name-suggestions-'+contentId).length){$('#wplf-name-suggestions-'+contentId).addClass('wplf-d-none')}})}
65if(searchButton.length>0){$(searchButton[0]).click(function(){performSearch(addressInput,contentId)})}
66if(geolocateButton.length>0){$(geolocateButton[0]).click(function(){dlxSearchCountry[contentId]='';dlxSearchIsCountry[contentId]=!1;
66var dlxCountryEl=document.getElementById('country-'+contentId);if(dlxCountryEl){if(dlxCountryEl._dlxChoices){dlxCountryEl._dlxChoices.setChoiceByValue('')}else{dlxCountryEl.value=''}}
67wplfGetCurrentPosition(contentId,!0)})}
68if(listMap){listMap.off('click').on('click',function(e){e.preventDefault();if(e.target.closest('.wplf-route-btn')){const wrapper=e.target.closest('.map-list-wrapper');const locationLat=parseFloat(wrapper.getAttribute('data-lat'));const locationLng=parseFloat(wrapper.getAttribute('data-lng'));if(osmLat!=''&&osmLng!=''){var origin={lat:parseFloat(osmLat),lng:parseFloat(osmLng)}}else{var origin={lat:parseFloat(userLat),lng:parseFloat(userLng)}}
69const destination={lat:locationLat,lng:locationLng};showDirections(origin,destination,markers,wplfMarkerClusterer,contentId,wrapper);if(panorama){panorama.setVisible(!1)}}
70if(e.target.closest('.wplf-dlx-cta-btn')){const ctaUrl=e.target.closest('.wplf-dlx-cta-btn').getAttribute('href');if(ctaUrl){window.open(ctaUrl,'_blank','noopener')}}
71if(e.target.closest('.wplf-detail-btn')){const detailButton=e.target.closest('.wplf-detail-btn');const url=detailButton.getAttribute('href');if(url){window.open(url,'_blank')}}
72if(e.target.closest('.wplf-contact-btn')){const contactButton=e.target.closest('.wplf-contact-btn');const url=contactButton.getAttribute('href');if(url){window.open(url,'_blank')}}})}
73$(this).find('.btn-search').click(function(){performSearch(addressInput,contentId);$(this).closest('.wplf-form-search').find('.btn-search-clear').show()})
74$(this).find('.btn-search-clear').click(function(){$(this).closest('.wplf-form-search').find('input[name="address_search"]').val('');dlxSearchCountry[contentId]='';dlxSearchIsCountry[contentId]=!1;$(this).addClass('wplf-d-none');loadLocations(userLat,userLng,contentId)})
75$(this).find('.wplf-map-direction-expand').off('click').on('click',function(){const mapContent=$('#wplf-map-content-'+contentId);if(mapContent.hasClass('wplf-direction-collapsed')){mapContent.removeClass('wplf-direction-collapsed');mapContent.addClass('wplf-direction-active');$(this).find('span').text('Collapse')}else{mapContent.addClass('wplf-direction-collapsed');mapContent.removeClass('wplf-direction-active');$(this).find('span').text('Expand')}
76if(map_provider=='google'){google.maps.event.trigger(wplfMaps[contentId],'resize')}else{wplfMaps[contentId].invalidateSize()}})})}
77function initSingleMaps(userLat,userLng){var maps=$('.wplf-single-map');maps.each(function(){var locationId=$(this).data('id');var lat=parseFloat($(this).data('lat'));var lng=parseFloat($(this).data('lng'));var markerIcon=$(this).data('marker');var isDefaultMarker=$(this).data('isdefaultmarker');var isGoogleIcon=$(this).data('isgoogleicon');var singleMapZoom=$(this).data('zoom');var singleImg=$(this).data('img');var singleName=$(this).data('name');var singleAddress=$(this).data('address');var singleContact=$(this).data('contact');var singleMap=new google.maps.Map($('#wplf-map-'+locationId)[0],{center:{lat:lat,lng:lng},zoom:singleMapZoom,mapTypeControl:!1,streetViewControl:!1,rotateControl:!1,cameraControl:!1,zoomControl:!0,mapId:mapId,mapTypeId:google_map_type});switch(google_map_layer){case 'traffic':new google.maps.TrafficLayer().setMap(singleMap);break;case 'transit':new google.maps.TransitLayer().setMap(singleMap);break;case 'bicycling':new google.maps.BicyclingLayer().setMap(singleMap);break;case 'kml':if(google_map_layer_url!==''){new google.maps.KmlLayer({url:google_map_layer_url,map:singleMap,preserveViewport:!0})}
78break}
79let markerContent;if(markerIcon.startsWith("<svg")){const parser=new DOMParser();const pinSvgString=markerIcon;markerContent=parser.parseFromString(pinSvgString,"image/svg+xml").documentElement}else{markerContent=document.createElement("img");markerContent.src=markerIcon;markerContent.width=40;markerContent.height=40}
80const singleMarker=new google.maps.marker.AdvancedMarkerElement({position:{lat:lat,lng:lng},map:singleMap,content:markerContent});const singleInfoWindow=new google.maps.InfoWindow({content:`
81                	<div class="wplf-map-marker">
82					    <div class="wplf-map-marker-close">
83					        <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
84								<path d="M8.4 17L7 15.6L10.6 12L7 8.42502L8.4 7.02502L12 10.625L15.575 7.02502L16.975 8.42502L13.375 12L16.975 15.6L15.575 17L12 13.4L8.4 17Z" fill="white"></path>
85							</svg>
86					    </div>
87					    <div class="wplf-map-marker-header">
88					        <div class="wplf-map-marker-image"><img src="${singleImg}"></div>
89					    </div>
90					    <div class="wplf-map-marker-body">
91						    <div class="wplf-map-marker-content">
92						    	<span class="wplf-map-marker-title">${singleName}</span>
93						        <span class="wplf-map-marker-address">${singleAddress}</span>
94						    </div>
95						    <div class="wplf-map-marker-footer">
96	                            <a class="wplf-details-icon" id="wplf-route-btn" href="https://www.google.com/maps/dir/?api=1&origin=${userLat},${userLng}&destination=${lat},${lng}" target="_blank">
97	                                <img src="${wplf_params.icon_route}" alt="${wplf_translate.route}">
98	                                <span>${wplf_translate.route}</span>
99	                            </a>
100	                            <a class="wplf-details-icon" id="wplf-street-view-btn" href="https://www.google.com/maps/place/${lat},${lng}" target="_blank">
101	                                <img src="${wplf_params.icon_street}" alt="${wplf_translate.street_view}">
102	                                <span>${wplf_translate.street_view}</span>
103	                            </a>
104						    </div>
105					    </div>
106					</div>
107                `});singleMarker.addListener('click',function(){singleInfoWindow.open(singleMap,singleMarker)});$(document).on('click','.wplf-map-marker-close',function(){singleInfoWindow.close()});wplfSetMapHeight(locationId);$(window).resize(function(){wplfSetMapHeight(locationId)})})}
108function initWplfSubmissionMaps(){var defaultLat=-34.397,defaultLng=150.644;$('.wplf-submission-form').each(function(){var contentId=$(this).data('id');var addressInputSearch=$(this).find('.address_search');var latVal=parseFloat($('#wplf-submission-form-'+contentId+' .latitude').val());var lngVal=parseFloat($('#wplf-submission-form-'+contentId+' .longitude').val());var lat=defaultLat;var lng=defaultLng;if(!isNaN(latVal)&&!isNaN(lngVal)){lat=latVal;lng=lngVal}
109if(map_provider=='google'){wplfSubmissionMaps[contentId]=new google.maps.Map($('#wplf-submission-map-'+contentId)[0],{center:{lat:lat,lng:lng},zoom:12,zoomControl:!0,rotateControl:!1,cameraControl:!1,mapId:mapId,mapTypeId:google_map_type});switch(google_map_layer){case 'traffic':new google.maps.TrafficLayer().setMap(wplfSubmissionMaps[contentId]);break;case 'transit':new google.maps.TransitLayer().setMap(wplfSubmissionMaps[contentId]);break;case 'bicycling':new google.maps.BicyclingLayer().setMap(wplfSubmissionMaps[contentId]);break;case 'kml':if(google_map_layer_url!==''){new google.maps.KmlLayer({url:google_map_layer_url,map:wplfSubmissionMaps[contentId],preserveViewport:!0})}
110break}
111if(!isNaN(latVal)&&!isNaN(lngVal)){wplfSubmissionMarkers[contentId]=new google.maps.marker.AdvancedMarkerElement({position:{lat:lat,lng:lng},map:wplfSubmissionMaps[contentId],draggable:!0})}else{if(navigator.geolocation){navigator.geolocation.getCurrentPosition(function(position){userLat=position.coords.latitude;userLng=position.coords.longitude;const newPosition={lat:userLat,lng:userLng};wplfSubmissionMaps[contentId].setCenter(newPosition)})}}
112initializeAutocomplete(addressInputSearch[0],contentId,!0);if(wplfSubmissionMarkers[contentId]){google.maps.event.addListener(wplfSubmissionMarkers[contentId],'dragend',function(event){$('#wplf-submission-form-'+contentId+' .latitude').val(event.latLng.lat());$('#wplf-submission-form-'+contentId+' .longitude').val(event.latLng.lng());updateLocation(event.latLng,contentId)})}
113google.maps.event.addListener(wplfSubmissionMaps[contentId],'click',function(event){const clickedLocation=event.latLng;$('#wplf-submission-form-'+contentId+' .latitude').val(event.latLng.lat());$('#wplf-submission-form-'+contentId+' .longitude').val(event.latLng.lng());const newPosition={lat:event.latLng.lat(),lng:event.latLng.lng()};if(!wplfSubmissionMarkers[contentId]){wplfSubmissionMarkers[contentId]=new google.maps.marker.AdvancedMarkerElement({position:newPosition,map:wplfSubmissionMaps[contentId],draggable:!0});google.maps.event.addListener(wplfSubmissionMarkers[contentId],'dragend',function(e){$('#wplf-submission-form-'+contentId+' .latitude').val(e.latLng.lat());$('#wplf-submission-form-'+contentId+' .longitude').val(e.latLng.lng());updateLocation(e.latLng,contentId)})}else{wplfSubmissionMarkers[contentId].position=newPosition}
114updateLocation(clickedLocation,contentId)})}else{wplfSubmissionMaps[contentId]=L.map('wplf-submission-map-'+contentId).setVie
114w([lat,lng],12);L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',{attribution:'&copy; OpenStreetMap contributors'}).addTo(wplfSubmissionMaps[contentId]);var customIcon=L.icon({iconUrl:wplf_params.wplf_url+'admin/icons/marker/location_on.svg',iconSize:[40,40],iconAnchor:[20,40],popupAnchor:[0,-40]});if(!isNaN(latVal)&&!isNaN(lngVal)){wplfSubmissionMarkers[contentId]=L.marker([lat,lng],{icon:customIcon}).addTo(wplfSubmissionMaps[contentId])}
115wplfSubmissionMaps[contentId].on('click',function(e){var lat=e.latlng.lat;var lng=e.latlng.lng;$('#wplf-submission-form-'+contentId+' .latitude').val(lat);$('#wplf-submission-form-'+contentId+' .longitude').val(lng);if(wplfSubmissionMarkers[contentId]){wplfSubmissionMaps[contentId].removeLayer(wplfSubmissionMarkers[contentId])}
116wplfSubmissionMarkers[contentId]=L.marker([lat,lng],{icon:customIcon}).addTo(wplfSubmissionMaps[contentId]);updateLocation(e.latlng,contentId)});var locationiq_key=wplf_params.osm_api_key;var geocoderControlOptions={bounds:!1,markers:!1,attribution:null,expanded:!0,panToPoint:!1,params:{dedupe:1,}}
117var geocoderControl=new L.control.geocoder(locationiq_key,geocoderControlOptions).addTo(wplfSubmissionMaps[contentId]).on('select',function(e){updateLocation(e.latlng,contentId);if(wplfSubmissionMarkers[contentId]){wplfSubmissionMaps[contentId].removeLayer(wplfSubmissionMarkers[contentId])}
118wplfSubmissionMarkers[contentId]=L.marker([e.latlng.lat,e.latlng.lng],{icon:customIcon}).addTo(wplfSubmissionMaps[contentId]);$('#wplf-submission-form-'+contentId+' .latitude').val(e.latlng.lat);$('#wplf-submission-form-'+contentId+' .longitude').val(e.latlng.lng)}).on('error',function(error){if(error&&error.errorMessage&&error.errorCode==429){$.ajax({type:'POST',url:wplf_params.ajax_url,data:{action:'wplf_locationiq_limit_notice',wplf_nonce:wplf_params.nonce}})}});var searchBoxControl=$(this).find('.osm_search_box');var geocoderContainer=geocoderControl.getContainer();searchBoxControl.append(geocoderContainer);$('.leaflet-locationiq-input').attr('placeholder',wplf_translate.placeholder_search_address)}})}
119function wplfGetCurrentPosition(contentId,updateInput,isClearSearchInput,showResults=!0){if(navigator.geolocation){navigator.geolocation.getCurrentPosition(function(position){userLat=position.coords.latitude;userLng=position.coords.longitude;loadLocations(userLat,userLng,contentId);updateMapAndDistances(userLat,userLng);if(!isClearSearchInput&&showResults){$('#wplf-content-'+contentId).find('.wplf-form-search').addClass('wplf-d-none');$('#wplf-content-'+contentId).find('.wplf-location-list').removeClass('wplf-d-none')}
120if(updateInput){$('#wplf-content-'+contentId).find('.wplf-form-search .btn-search-clear').removeClass('wplf-d-none');var addressInput=$('#address_search-'+contentId);if(map_provider=='google'){const geocoder=new google.maps.Geocoder();const latLng=new google.maps.LatLng(userLat,userLng);geocoder.geocode({'location':latLng},function(results,status){if(status==='OK'&&results[0]){if(addressInput.length>0){addressInput.val(results[0].formatted_address)}}})}else{var geocodeUrl=`https://nominatim.openstreetmap.org/reverse?lat=${userLat}&lon=${userLng}&format=json`;$.getJSON(geocodeUrl,function(data){if(data&&data.display_name){if(addressInput.length>0){addressInput.val(data.display_name);$('#wplf-osm-search-box-'+contentId+' .leaflet-locationiq-input').val(data.display_name);$('#wplf-osm-search-box-'+contentId+' .leaflet-locationiq-close').removeClass('leaflet-locationiq-hidden');$('#wplf-osm-search-box-'+contentId+' .btn-search-action').css('right','35px')}}})}}},function(error){wplfGeolocation=!1;if(error.code===error.PERMISSION_DENIED){alert(wplf_translate.msg_location_access_required)}})}else{console.error(wplf_translate.msg_geolocation_not_supported)}}
121function initializeAutocomplete(input,contentId,isSubmission=!1){if(map_provider=='google'){var autocomplete=new google.maps.places.Autocomplete(input);google.maps.event.addListener(autocomplete,'place_changed',function(){onPlaceChanged(autocomplete,contentId,isSubmission)})}}
122function onPlaceChanged(autocomplete,contentId,isSubmission){if(map_provider=='google'){const place=autocomplete.getPlace();if(!place.geometry){return}
123if(!isSubmission){dlxSearchCountry[contentId]=dlxCountryFromComponents(place.address_components);dlxSearchIsCountry[contentId]=(place.types||[]).indexOf('country')!==-1;userLat=place.geometry.location.lat();userLng=place.geometry.location.lng();loadLocations(userLat,userLng,contentId);updateMapAndDistances(userLat,userLng)}else{const newPosition={lat:place.geometry.location.lat(),lng:place.geometry.location.lng()};wplfSubmissionMaps[contentId].setCenter(newPosition);if(!wplfSubmissionMarkers[contentId]){wplfSubmissionMarkers[contentId]=new google.maps.marker.AdvancedMarkerElement({position:newPosition,map:wplfSubmissionMaps[contentId],draggable:!0});google.maps.event.addListener(wplfSubmissionMarkers[contentId],'dragend',function(event){$('#wplf-submission-form-'+contentId+' .latitude').val(event.latLng.lat());$('#wplf-submission-form-'+contentId+' .longitude').val(event.latLng.lng());updateLocation(event.latLng,contentId)})}else{wplfSubmissionMarkers[contentId].position=newPosition}
124$('#wplf-submission-form-'+contentId+' .latitude').val(place.geometry.location.lat());$('#wplf-submission-form-'+contentId+' .longitude').val(place.geometry.location.lng());var fullAddress=place.formatted_address;updateLocationFields(place.address_components,contentId);$('#wplf-submission-form-'+contentId+' .address').val(fullAddress);$('#wplf-submission-form-'+contentId+' .wplf-full-address span').text(fullAddress);$('#wplf-submission-form-'+contentId+' .wplf-full-address').removeClass('wplf-d-none')}}}
125function performSearch(input,contentId){const inputValue=input.val();var nameSearchVal=$('#name_search-'+contentId).val();if(nameSearchVal&&nameSearchVal.trim()!==''){loadLocations(userLat,userLng,contentId);$('#wplf-content-'+contentId).find('.wplf-form-search').addClass('wplf-d-none');$('#wplf-content-'+contentId).find('.wplf-location-list').removeClass('wplf-d-none');$('#wplf-content-'+contentId).find('.wplf-back-btn').removeClass('wplf-d-none');return}
126if(!inputValue){alert(wplf_translate.msg_enter_address);return}
127$('.wplf-form-search .btn-search-clear').removeClass('wplf-d-none');if(map_provider=='google'){const geocoder=new google.maps.Geocoder();geocoder.geocode({address:inputValue},(results,status)=>{if(status===google.maps.GeocoderStatus.OK){if(results[0]){dlxSearchCountry[contentId]=dlxCountryFromComponents(results[0].address_components);dlxSearchIsCountry[contentId]=(results[0].types||[]).indexOf('country')!==-1;const location=results[0].geometry.location;wplfGeolocation=!0;userLat=location.lat();userLng=location.lng();loadLocations(userLat,userLng,contentId);updateMapAndDistances(userLat,userLng);$('#wplf-content-'+contentId).find('.wplf-form-search').addClass('wplf-d-none');$('#wplf-content-'+contentId).find('.wplf-location-list').removeClass('wplf-d-none');wplfMaps[contentId].setCenter(location)}else{$('#wplf-content-'+contentId).find('.wplf-form-search').addClass('wplf-d-none');$('#wplf-content-'+contentId).find('.wplf-location-list').removeClass('wplf-d-none');displayLocations([],contentId,0,0)}}else{$('#wplf-content-'+contentId).find('.wplf-form-search').addClass('wplf-d-none');$('#wplf-content-'+contentId).find('.wplf-location-list').removeClass('wplf-d-none');displayLocations([],contentId,0,0)}})}else{performOSMSearch(inputValue,contentId)}}
128async function performOSMSearch(inputValue,contentId,showResults=!0){try{if(osmLat!=''&&osmLng!=''){loadLocations(osmLat,osmLng,contentId);updateMapAndDistances(osmLat,osmLng)}else{const results=await geocodeOSMAddress(inputValue);if(results&&results.length>0){var location=results[0];userLat=location.lat;userLng=location.lon;loadLocations(userLat,userLng,contentId);updateMapAndDistances(userLat,userLng)}}
129if(showResults){$('#wplf-content-'+contentId).find('.wplf-form-search').addClass('wplf-d-none');$('#wplf-content-'+contentId).find('.wplf-location-list').removeClass('wplf-d-none')}}catch(error){wplfGetCurrentPosition(contentId,!1,!1)}}
130function displayLocations(locations,contentId,userLat,userLng){const listMap=document.querySelector('#list-map-'+contentId);if(listMap){listMap.innerHTML=''}
131let currentInfoWindow=null;markers[contentId]=[];if(map_provider=='google'){var bounds=new google.maps.LatLngBounds()}else{wplfMarkerClusterer[contentId]=L.markerClusterGroup()}
132if(locations.length===0){if(listMap){listMap.innerHTML=wplf_translate.msg_no_locations_foun
132d}
133return}
134var default_marker_url=$('#wplf-default_marker_url-'+contentId).val();const dlxDist=new Map();const dlxCountryMin={};locations.forEach(loc=>{const d=calculateDistance(userLat,userLng,parseFloat(loc.latitude),parseFloat(loc.longitude));dlxDist.set(loc,d);const c=String(loc.country||'').toUpperCase();if(!(c in dlxCountryMin)||d<dlxCountryMin[c])dlxCountryMin[c]=d});locations.sort((a,b)=>{const ca=String(a.country||'').toUpperCase(),cb=String(b.country||'').toUpperCase();if(ca!==cb)return dlxCountryMin[ca]-dlxCountryMin[cb];const ra=dlxRank(a),rb=dlxRank(b);if(ra!==rb)return ra-rb;return dlxDist.get(a)-dlxDist.get(b)});locations.forEach(location=>{const item=document.createElement('div');item.className='map-list-wrapper';item.setAttribute('data-lat',location.latitude);item.setAttribute('data-lng',location.longitude);if(location.name!==''){let markerIcon=location.marker;if(listMap){item.innerHTML=`
135	                    <div class="map-list-header">
136	                        ${markerIcon.startsWith('<svg')
137							? `<div class="wplf-svg-marker ${location.isDefaultMarker ? 'wplf-is-default-marker' : ''}">${markerIcon}</div>`
138							: `<img class="${location.isDefaultMarker ? 'wplf-is-default-marker' : ''}" src="${markerIcon}" alt="" width="32" height="32">`}
139	                        <div class="desc-list">
140	                            <span class="location-title">${location.name}</span>
141	                            <span class="location-address">${location.address}</span>
142	                            ${show_result_list_description && location.description ? `<div class="location-description">${location.description}</div>` : ''}
143	                        </div>
144	                        ${wplfGeolocation ? `<button class="wplf-distance">${wplf_translate.calculating}</button>` : ''}
145	                    </div>
146	                    <div class="map-list-footer">
147	                        ${wplfGeolocation ? `<a class="wplf-route-btn wplf-action-btn"><img src="${wplf_params.icon_route}" alt="${wplf_translate.route}">${wplf_translate.route}</a>` : ''
148						}
149	                        <a class="wplf-detail-btn wplf-action-btn" href="${location.post_url}" target="_blank">
150	                            <img src="${wplf_params.icon_details}" alt="${wplf_translate.details}"> ${wplf_translate.details}
151	                        </a>
152	                        ${location.contactURL !== '' ? `<a href="${location.contactURL}" class="wplf-contact-btn wplf-action-btn"><img src="${wplf_params.icon_contact}" alt="${wplf_translate.contact}">${wplf_translate.contact}</a>` : ''}
153	                        ${dlxCtaHtml(location, 'list')}
154	                    </div>
155	                `;listMap.appendChild(item)}
156let markerContent;if(markerIcon.startsWith("<svg")){const parser=new DOMParser();const pinSvgString=markerIcon;markerContent=parser.parseFromString(pinSvgString,"image/svg+xml").documentElement}else{markerContent=document.createElement("img");markerContent.src=markerIcon;markerContent.width=40;markerContent.height=40}
157if(map_provider==='google'){const marker=new google.maps.marker.AdvancedMarkerElement({position:{lat:parseFloat(location.latitude),lng:parseFloat(location.longitude)},map:wplfMaps[contentId],title:location.name,content:markerContent});marker.location={lat:parseFloat(location.latitude),lng:parseFloat(location.longitude)};markers[contentId].push(marker);bounds.extend(marker.position);const infoWindow=new google.maps.InfoWindow({content:`
158	                    	<div class="wplf-map-marker">
159							    <div class="wplf-map-marker-close">
160							        <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
161										<path d="M8.4 17L7 15.6L10.6 12L7 8.42502L8.4 7.02502L12 10.625L15.575 7.02502L16.975 8.42502L13.375 12L16.975 15.6L15.575 17L12 13.4L8.4 17Z" fill="white"></path>
162									</svg>
163							    </div>
164							    <div class="wplf-map-marker-header">
165							        <div class="wplf-map-marker-image"><img src="${location.featured_img}"></div>
166							    </div>
167							    <div class="wplf-map-marker-body">
168								    <div class="wplf-map-marker-content">
169								    	<span class="wplf-map-marker-title">${location.name}</span>
170								        <span class="wplf-map-marker-address">${location.address}</span>
171	                    				${show_marker_description && location.description ? `<div class="wplf-map-marker-description">${location.description}</div>` : ''}
172								    </div>
173								    <div class="wplf-map-marker-footer">
174			                            <a class="wplf-details-icon" id="wplf-route-btn" href="https://www.google.com/maps/dir/?api=1&origin=${userLat},${userLng}&destination=${location.latitude},${location.longitude}" target="_blank">
175			                                <img src="${wplf_params.icon_route}" alt="${wplf_translate.route}">
176			                                <span>${wplf_translate.route}</span>
177			                            </a>
178								    	<a class="wplf-details-icon" href="${location.post_url}" ${open_detail_new_tab ? 'target="_blank"' : ''}>
179			                                <img src="${wplf_params.icon_details}" alt="${wplf_translate.details}">
180			                                <span>${wplf_translate.details}</span>
181			                            </a>
182			                            ${location.contactURL !== '' ? `<a class="wplf-details-icon" href="${location.contactURL}"><img src="${wplf_params.icon_contact}" alt="${wplf_translate.contact}"><span>${wplf_translate.contact}</span></a>` : ''}
183			                            ${dlxCtaHtml(location, 'popup')}
184			                            <a class="wplf-details-icon" id="wplf-street-view-btn" href="https://www.google.com/maps/place/${location.latitude},${location.longitude}" target="_blank">
185			                                <img src="${wplf_params.icon_street}" alt="${wplf_translate.street_view}">
186			                                <span>${wplf_translate.street_view}</span>
187			                            </a>
188								    </div>
189							    </div>
190							</div>
191	                    `});marker.addListener('click',function(){if(currentInfoWindow){currentInfoWindow.close()}
192infoWindow.open(wplfMaps[contentId],marker);currentInfoWindow=infoWindow});item.addEventListener('click',function(e){if(e.target.closest('.wplf-action-btn')){return}
193$('#wplf-content-'+contentId).find('.map-list-wrapper').removeClass('active');item.classList.add('active');var lat=parseFloat(item.getAttribute('data-lat'));var lng=parseFloat(item.getAttribute('data-lng'));var markerToOpen=markers[contentId].find(m=>m.location.lat===lat&&m.location.lng===lng);if(markerToOpen){google.maps.event.trigger(markerToOpen,'click');wplfMaps[contentId].setCenter(markerToOpen.location);wplfMaps[contentId].setZoom(13);if(panorama){panorama.setVisible(!1)}}});google.maps.event.addListener(infoWindow,'domready',function(){const streetViewButton=$('#wplf-street-view-btn');if(streetViewButton.length>0){streetViewButton.off('click').on('click',function(e){e.preventDefault();panorama=wplfMaps[contentId].getStreetView();panorama.setPosition({lat:parseFloat(location.latitude),lng:parseFloat(location.longitude)});panorama.setPov({heading:165,pitch:0});panorama.setVisible(!0)})}
194$(document).off('click').on('click','#wplf-route-btn',function(e){e.preventDefault();const origin={lat:parseFloat(userLat),lng:parseFloat(userLng),};const destination={lat:parseFloat(location.latitude),lng:parseFloat(location.longitude),};showDirections(origin,destination,markers,wplfMarkerClusterer,contentId,$(this))})
195$(document).on('click','.wplf-map-marker-close',function(){infoWindow.close()})})}else{var customIcon=L.divIcon({className:"custom-marker",html:markerContent,iconSize:[40,40],iconAnchor:[20,40],popupAnchor:[0,-40]});const marker=L.marker([parseFloat(location.latitude),parseFloat(location.longitude)],{icon:customIcon});markers[contentId].push(marker);const infoWindow=`
196                    	<div class="wplf-map-marker">
197						    <div class="wplf-map-marker-close" onclick="wplfClosePopup('${contentId}', false)">
198						        <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
199									<path d="M8.4 17L7 15.6L10.6 12L7 8.42502L8.4 7.02502L12 10.625L15.575 7.02502L16.975 8.42502L13.375 12L16.975 15.6L15.575 17L12 13.4L8.4 17Z" fill="white"></path>
200								</svg>
201						    </div>
202						    <div class="wplf-map-marker-header">
203						        <div class="wplf-map-marker-image"><img src="${location.featured_img}"></div>
204						    </div>
205						    <div class="wplf-map-marker-body">
206							    <div class="wplf-map-marker-content">
207							    	<span class="wplf-map-marker-title">${location.name}</span>
208							        <span class="wplf-map-marker-address">${location.address}</span>
209			        				${show_marker_description && location.description ? `<div class="wplf-map-marker-description">${location.description}</div>` : ''}
210							    </div>
211							    <div class="wplf-map-marker-footer">
212							    	${wplfGeolocation ? `<a class="wplf-details-icon"
213id="wplf-route-btn"
214href="https://www.google.com/maps/dir/?api=1&origin=${userLat},${userLng}&destination=${location.latitude},${location.longitude}"
215target="_blank"
216data-u-lat="${userLat}"
217data-u-lng="${userLng}"
218data-location-lat="${location.latitude}"
219data-location-lng="${location.longitude}"><img src="${wplf_params.icon_route}" alt="${wplf_translate.route}"><span>${wplf_translate.route}</span></a>` : ''
220						}
221							    	<a class="wplf-details-icon" href="${location.post_url}" ${open_detail_new_tab ? 'target="_blank"' : ''}>
222		                                <img src="${wplf_params.icon_details}" alt="${wplf_translate.details}">
223		                                <span>${wplf_translate.details}</span>
224		                            </a>
225		                            ${location.contactURL !== '' ? `<a class="wplf-details-icon" href="${location.contactURL}"><img src="${wplf_params.icon_contact}" alt="${wplf_translate.contact}"><span>${wplf_translate.contact}</span></a>` : ''}
226		                            <a class="wplf-details-icon" id="wplf-street-view-btn" href="https://www.google.com/maps/place/${location.latitude},${location.longitude}" target="_blank">
227		                                <img src="${wplf_params.icon_street}" alt="${wplf_translate.street_view}">
228		                                <span>${wplf_translate.street_view}</span>
229		                            </a>
230							    </div>
231						    </div>
232						</div>
233                    `;marker.bindPopup(infoWindow);wplfMarkerClusterer[contentId].addLayer(marker);marker.on('click',function(){wplfMaps[contentId].setView([parseFloat(location.latitude),parseFloat(location.longitude)],13)});item.addEventListener('click',function(){$('#wplf-content-'+contentId).find('.map-list-wrapper').removeClass('active');item.classList.add('active');const lat=parseFloat(item.getAttribute('data-lat'));const lng=parseFloat(item.getAttribute('data-lng'));const markerToOpen=markers[contentId].find(m=>m.getLatLng().lat===lat&&m.getLatLng().lng===lng);if(markerToOpen){wplfMaps[contentId].closePopup();setTimeout(()=>{markerToOpen.openPopup()},200);wplfMaps[contentId].setView([lat,lng],13)}});wplfMaps[contentId].on('popupopen',function(e){const popupEl=$(e.popup.getElement());popupEl.find('.wplf-map-marker-close').off('click').on('click',function(){wplfMaps[contentId].closePopup()});const routeBtn=popupEl.find('#wplf-route-btn');if(routeBtn.length>0){routeBtn.off('click').on('click',function(e){e.preventDefault();const origin={lat:parseFloat($(this).data('u-lat')),lng:parseFloat($(this).data('u-lng')),};const destination={lat:parseFloat($(this).data('location-lat')),lng:parseFloat($(this).data('location-lng')),};const targetItem=$('#wplf-content-'+contentId).find('.map-list-wrapper').filter(function(){return(parseFloat(this.dataset.lat)===destination.lat&&parseFloat(this.dataset.lng)===destination.lng)}).first();showDirections(origin,destination,markers,wplfMarkerClusterer,contentId,targetItem)})}})}}});var currentMap=wplfMaps[contentId];var currentMarkers=markers[contentId];if(map_provider==='google'){class CustomRenderer extends markerClusterer.DefaultRenderer{render(cluster,stats,map){const marker=super.render(cluster,stats,map);if(marker){const count=cluster.count;const template=wplf_translate.cluster_title||'Cluster of %d markers';const title=template.replace('%d',count);if(marker.setTitle){marker.setTitle(title)}else{marker.title=title}}
234return marker}}
235wplfMarkerClusterer[contentId]=new markerClusterer.MarkerClusterer({map:currentMap,markers:currentMarkers,renderer:new CustomRenderer()})}else{currentMap.addLayer(wplfMarkerClusterer[contentId])}
236var map_zoom=parseInt($('#wplf-map_zoom-'+contentId).val());if(dlxFitMode[contentId]==='nearby'&&map_provider==='google'&&currentMarkers&&currentMarkers.length){var dlxNear=new google.maps.LatLngBounds();dlxNear.extend({lat:parseFloat(userLat),lng:parseFloat(userLng)});currentMarkers.slice().sort(function(a,b){return calculateDistance(userLat,userLng,a.location.lat,a.location.lng)-calculateDistance(userLat,userLng,b.location.lat,b.location.lng)}).slice(0,3).forEach(function(m){dlxNear.extend(m.location)});currentMap.fitBounds(dlxNear);google.maps.event.addListenerOnce(currentMap,'idle',function(){if(currentMap.getZoom()>13)currentMap.setZoom(13)})}else if(dlxCountryActive[contentId]&&map_provider==='google'&&currentMarkers&&currentMarkers.length){currentMap.fitBounds(bounds);google.maps.event.addListenerOnce(currentMap,'idle',function(){if(currentMap.getZoom()>13)currentMap.setZoom(13)})}else if(map_zoom==0){if(map_provider==='google'){currentMap.fitBounds(bounds)}else{currentMap.fitBounds(wplfMarkerClusterer[contentId].getBounds())}}}
237function loadLocations(userLat,userLng,contentId){var address_value='',radius='',country_value='',category_value='',allTags='',tag_value='';if($('#address_search-'+contentId).length>0){address_value=$('#address_search-'+contentId).val();
237radius=$('#wplf-radius-'+contentId).length>0?$('#wplf-radius-'+contentId).val():'';country_value=$('#country-'+contentId).length>0?$('#country-'+contentId).val():'';category_value=$('#wplf-category-'+contentId).length>0?$('#wplf-category-'+contentId).val():'';allTags=$('#wplf-content-'+contentId).find('.wplf-tag:checked').length>0?$('#wplf-content-'+contentId).find('.wplf-tag:checked').map(function(){return $(this).val()}).get():[];tag_value=allTags.join(',');tag_value=allTags.join(',')}else{address_value=$('#wplf-default_address-'+contentId).length>0?$('#wplf-default_address-'+contentId).val():''}
238var dlxDropdownCountry=country_value;if(!country_value&&dlxSearchCountry[contentId]){country_value=dlxSearchCountry[contentId]}
239dlxCountryActive[contentId]=!!country_value;if(dlxSearchCountry[contentId]&&!dlxSearchIsCountry[contentId]&&(!dlxDropdownCountry||String(dlxDropdownCountry).toUpperCase()===dlxSearchCountry[contentId])){dlxFitMode[contentId]='nearby'}else{dlxFitMode[contentId]=country_value?'country':''}
240var location_name='';if($('#name_search-'+contentId).length>0){location_name=$('#name_search-'+contentId).val()}
241var filter_cat=$('#wplf-filter_cat-'+contentId).val();var filter_tag=$('#wplf-filter_tag-'+contentId).val();var map_zoom=parseInt($('#wplf-map_zoom-'+contentId).val());$("#wplf-loading-fetch").removeClass('d-none');$('#list-map').html('');var data={country:country_value,category:category_value,filter_cat:filter_cat,tag:tag_value,filter_tag:filter_tag,address:address_value,location_name:location_name,action:'wplf_get_locations'};jQuery.ajax({url:wplf_params.ajax_url,type:'GET',data,}).then(locations=>{if(locations.length>0){if(map_zoom==0){var totalLat=0;var totalLng=0;locations.forEach(location=>{totalLat+=parseFloat(location.latitude);totalLng+=parseFloat(location.longitude)});var centerLat=totalLat/locations.length;var centerLng=totalLng/locations.length}else{var centerLat=userLat;var centerLng=userLng}}else{var centerLat=userLat;var centerLng=userLng}
242if(map_provider=='google'){wplfMaps[contentId]=new google.maps.Map($('#wplf-map-'+contentId)[0],{center:{lat:centerLat,lng:centerLng},zoom:map_zoom,mapTypeControl:!1,streetViewControl:!1,rotateControl:!1,cameraControl:!1,zoomControl:!0,mapId:mapId,mapTypeId:google_map_type});switch(google_map_layer){case 'traffic':new google.maps.TrafficLayer().setMap(wplfMaps[contentId]);break;case 'transit':new google.maps.TransitLayer().setMap(wplfMaps[contentId]);break;case 'bicycling':new google.maps.BicyclingLayer().setMap(wplfMaps[contentId]);break;case 'kml':if(google_map_layer_url!==''){new google.maps.KmlLayer({url:google_map_layer_url,map:wplfMaps[contentId],preserveViewport:!0})}
243break}}else{wplfMaps[contentId]=wplfMaps[contentId].setView([centerLat,centerLng]);if(wplfMarkerClusterer[contentId]){wplfMarkerClusterer[contentId].clearLayers()}}
244if(locations.length==0){wplfMaps[contentId].setZoom(10)}
245locations=filterLocations(locations,radius,userLat,userLng,country_value);displayLocations(locations,contentId,userLat,userLng);updateMapAndDistances(userLat,userLng);$('#wplf-loading-fetch, #wplf-map-direction-content').addClass('wplf-d-none')}).catch(error=>{alert(wplf_translate.msg_error_loading_locations)})}
246function filterLocations(locations,radius,userLat,userLng,country){var selectedCountry=country;var filtered=[];if(radius>0){filtered=locations.filter(location=>{const lat1=parseFloat(location.latitude);const lon1=parseFloat(location.longitude);const distance=calculateDistance(userLat,userLng,lat1,lon1);return distance<=radius})}else{filtered=locations.slice()}
247if(selectedCountry!==''){filtered=filtered.filter(location=>{return String(selectedCountry).toUpperCase()===String(location.country||'').toUpperCase()})}
248return filtered}
249function updateMapAndDistances(userLat,userLng){if(!wplfGeolocation){return}
250document.querySelectorAll('.map-list-wrapper').forEach(function(element){const locationLat=parseFloat(element.getAttribute('data-lat'));const locationLng=parseFloat(element.getAttribute('data-lng'));const distance=calculateDistance(userLat,userLng,locationLat,locationLng);if(element.querySelector('.wplf-distance')){element.querySelector('.wplf-distance').textContent=`${distance.toFixed(1)} ${distance_unit}`}})}
251function calculateDistance(lat1,lon1,lat2,lon2){const R=(distance_unit==='km')?6371:3959;const dLat=deg2rad(lat2-lat1);const dLon=deg2rad(lon1-lon2);const a=Math.sin(dLat/2)*Math.sin(dLat/2)+Math.cos(deg2rad(lat1))*Math.cos(deg2rad(lat2))*Math.sin(dLon/2)*Math.sin(dLon/2);const c=2*Math.atan2(Math.sqrt(a),Math.sqrt(1-a));const distance=R*c;return distance}
252function deg2rad(deg){return deg*(Math.PI/180)}
253function showDirections(origin,destination,markers,wplfMarkerClusterer,contentId,element){if(map_provider=='google'){if(!directionsService[contentId])directionsService[contentId]=new google.maps.DirectionsService();if(!directionsRenderer[contentId]){directionsRenderer[contentId]=new google.maps.DirectionsRenderer();
253directionsRenderer[contentId].setMap(wplfMaps[contentId]);directionsRenderer[contentId].setPanel(document.getElementById('wplf-map-direction-'+contentId))}
254directionsRenderer[contentId].setDirections({routes:[]});const directionsPanel=document.getElementById('wplf-map-direction-'+contentId);if(directionsPanel){directionsPanel.innerHTML=''}
255markers[contentId].forEach(marker=>{marker.setMap(null)});if(wplfMarkerClusterer[contentId]){wplfMarkerClusterer[contentId].clearMarkers()}
256const request={origin:origin,destination:destination,travelMode:google.maps.TravelMode.DRIVING};$('#wplf-map-direction-summary-'+contentId+', #wplf-map-direction-'+contentId).hide();$('#wplf-map-content-'+contentId).addClass('wplf-direction-active');$('#wplf-map-direction-content-'+contentId+', #wplf-direction-loading-'+contentId).removeClass('wplf-d-none');$('#wplf-location-list-'+contentId).addClass('wplf-d-none');$('#wplf-map-direction-expand-'+contentId).removeClass('wplf-disable');if(!$('#wplf-form-search-'+contentId).hasClass('wplf-d-none')){$('#wplf-form-search-'+contentId).addClass('wplf-d-none')}
257directionsService[contentId].route(request,(result,status)=>{if(status===google.maps.DirectionsStatus.OK){directionsRenderer[contentId].setDirections(result);const route=result.routes[0];const leg=route.legs[0];$("#wplf-start-address-"+contentId).val(leg.start_address);$("#wplf-end-address-"+contentId).val(leg.end_address);var intervalGetSummary=setInterval(function(){var summary=$('#wplf-content-'+contentId).find('.adp-summary');if(summary.length>0){$('#wplf-content-'+contentId).find('.wplf-map-direction-summary').html(summary.text());$('#wplf-content-'+contentId).find('.wplf-map-direction-summary, .wplf-map-direction').show();$('#wplf-direction-loading-'+contentId).addClass('wplf-d-none');clearInterval(intervalGetSummary)}},1000)}else{const geocoder=new google.maps.Geocoder();geocoder.geocode({location:request.origin},(res,geocodeStatus)=>{if(geocodeStatus===google.maps.GeocoderStatus.OK&&res.length>0){$("#wplf-start-address"+contentId).val(res[0].formatted_address)}});geocoder.geocode({location:request.destination},(res,geocodeStatus)=>{if(geocodeStatus===google.maps.GeocoderStatus.OK&&res.length>0){$("#wplf-end-address"+contentId).val(res[0].formatted_address)}});$('#wplf-direction-loading-'+contentId).addClass('wplf-d-none');$('#wplf-map-direction-expand-'+contentId).addClass('wplf-disable');$('#wplf-content-'+contentId).find('.wplf-map-direction-summary').html(wplf_translate.msg_cannot_find_directions).show()}})}else{$('#wplf-map-direction-summary-'+contentId+', #wplf-map-direction-'+contentId).hide();$('#wplf-map-content-'+contentId).addClass('wplf-direction-active');$('#wplf-map-direction-content-'+contentId+', #wplf-direction-loading-'+contentId).removeClass('wplf-d-none');$('#wplf-location-list-'+contentId).addClass('wplf-d-none');$('#wplf-map-direction-expand-'+contentId).removeClass('wplf-disable');if(!$('#wplf-form-search-'+contentId).hasClass('wplf-d-none')){$('#wplf-form-search-'+contentId).addClass('wplf-d-none')}
258var startPoint=L.latLng(origin.lat,origin.lng);var endPoint=L.latLng(destination.lat,destination.lng);if(wplfMarkerClusterer[contentId]){wplfMarkerClusterer[contentId].clearLayers()}
259wplfRouteControl[contentId]=L.Routing.control({waypoints:[startPoint,endPoint],createMarker:function(){return null},routeWhileDragging:!0,show:!1}).on('routingerror',function(e){$('#wplf-content-'+contentId).find('.wplf-map-direction').html(wplf_translate.msg_cannot_find_directions).show()}).addTo(wplfMaps[contentId]);var $element=(element instanceof jQuery)?element:$(element);$('#wplf-start-address-'+contentId).val($('#address_search-'+contentId).val());$('#wplf-end-address-'+contentId).val($element.find('.location-address').text());var startLatLng=wplfRouteControl[contentId].getWaypoints()[0].latLng;var endLatLng=wplfRouteControl[contentId].getWaypoints()[1].latLng;if(wplfRouteControl[contentId]){$('#wplf-content-'+contentId).find('.wplf-map-direction').html(wplfRouteControl[contentId].getContainer()).show()}
260$('#wplf-direction-loading-'+contentId).addClass('wplf-d-none')}
261$(document).off('click').on('click','#wplf-close-direction-'+contentId,function(){$(this).closest('.wplf-map-content').removeClass('wplf-direction-active wplf-direction-collapsed');$(this).closest('.wplf-map-content').find('.wplf-map-direction-content').addClass('wplf-d-none');$(this).closest('.wplf-map-content').find('.wplf-location-list').removeClass('wplf-d-none');if(map_provider=='google'){if(directionsRenderer[contentId]){directionsRenderer[contentId].setDirections({routes:[]})}
262markers[contentId].forEach(marker=>{marker.setMap(wplfMaps[contentId])});if(wplfMarkerClusterer[contentId]){wplfMarkerClusterer[contentId].addMarkers(markers[contentId])}}else{markers[contentId].forEach(marker=>{wplfMarkerClusterer[contentId].addLayer(marker)});if(wplfRouteControl[contentId]){wplfRouteControl[contentId].remove()}}})}
263function geocodeOSMLatLng(latLng,callback){var url=`https://nominatim.openstreetmap.org/reverse?format=json&lat=${latLng.lat}&lon=${latLng.lng}`;$.get(url,function(data){if(data&&data.address){callback(data.address)}})}
264function geocodeOSMAddress(address){var url=`https://nominatim.openstreetmap.org/search?format=json&limit=5&addressdetails=1&q=${encodeURIComponent(address)}`;return $.ajax({url:url,method:'GET'})}
265function formatOSMAddress(address){var formattedAddress="";if(address.road){formattedAddress+=address.road+", "}
266if(address.village){formattedAddress+=address.village+", "}
267if(address.city_district){formattedAddress+=address.city_district+", "}
268if(address.city){formattedAddress+=address.city+", "}
269if(address.country){formattedAddress+=address.country}
270return formattedAddress}
271function updateLocation(location,contentId){if(map_provider=='google'){const geocoder=new google.maps.Geocoder();geocoder.geocode({location:location},function(results,status){if(status==='OK'&&results[0]){const components=results[0].address_components;updateLocationFields(components,contentId);var fullAddress=results[0].formatted_address;$('#wplf-submission-form-'+contentId+' .address').val(fullAddress);$('#wplf-submission-form-'+contentId+' .wplf-full-address span').text(fullAddress);$('#wplf-submission-form-'+contentId+' .wplf-full-address').removeClass('wplf-d-none')}else{console.error(wplf_admin_translate.msg_geocoder_status+": "+status)}})}else{var geocodeUrl=`https://nominatim.openstreetmap.org/reverse?lat=${location.lat}&lon=${location.lng}&format=json`;$.getJSON(geocodeUrl,function(data){if(data&&data.address){$('#wplf-submission-form-'+contentId+' .city').val(data.address.city||'');$('#wplf-submission-form-'+contentId+' .state').val(data.address.state||'');$('#wplf-submission-form-'+contentId+' .country').val(data.address.country||'');$('#wplf-submission-form-'+contentId+' .country_code').val(data.address.country_code||'');$('#wplf-submission-form-'+contentId+' .zip_code').val(data.address.postcode||'');if(data.display_name){$('#wplf-submission-form-'+contentId+' .address').val(data.display_name);$('#wplf-submission-form-'+contentId+' .wplf-full-address span').text(data.display_name);$('#wplf-submission-form-'+contentId+' .wplf-full-address').removeClass('wplf-d-none')}}})}}
272function updateLocationFields(address_components,contentId){var city='';var state='';var country='';var countryCode='';var zipCode='';var address='';address_components.forEach(component=>{var types=component.types;if(types.includes('premise')){address=component.long_name}else if(types.includes('street_number')){address+=' '+component.long_name}else if(types.includes('route')){address+=' '+component.long_name}else if(types.includes('neighborhood')){var neighborhood=component.long_name;if(!address){address=neighborhood}else{address+=' '+neighborhood}}else if(types.includes('administrative_area_level_2')){state=component.short_name}else if(types.includes('administrative_area_level_1')){city=component.short_name}else if(types.includes('locality')){if(!city){city=component.long_name}}else if(types.includes('country')){country=component.long_name;countryCode=component.short_name}else if(types.includes('postal_code')){zipCode=component.long_name}else if(types.includes('plus_code')){var plusCode=component.long_name;if(address){address+=' '+plusCode}else{address=plusCode}}});$('#wplf-submission-form-'+contentId+' .country').val(country);$('#wplf-submission-form-'+contentId+' .country_code').val(countryCode);$('#wplf-submission-form-'+contentId+' .city').val(city);$('#wplf-submission-form-'+contentId+' .state').val(state);$('#wplf-submission-form-'+contentId+' .zip_code').val(zipCode);return address}
273function wplfSetMapHeight(locationId){var $map=$('#wplf-map-'+locationId);var width=$map.width();var height;var screenWidth=$(window).width();if(screenWidth<=960){height=width*(550/900)}else{height=width*(640/790)}
274$map.height(height)}
275function wplfAdjustGalleryImages(){const frame=$('.wplf-single-frame');const gallery=$('.wplf-galleries');const images=gallery.find('img');const frameWidth=frame.width();const gap=8;if(images.length===0)return;var windowWidth=$(window).width();var imgWidth=115;if(windowWidth<480){imgWidth=60}else if(windowWidth<768){imgWidth=70}else if(windowWidth<960){imgWidth=98}else if(windowWidth<1366){imgWidth=80}
276let numImagesInRow=Math.floor((frameWidth+gap)/(imgWidth+gap));if(numImagesInRow<1)numImagesInRow=1;const totalGapWidth=(numImagesInRow-1)*gap;const optimalImageWidth=(frameWidth-totalGapWidth)/numImagesInRow;images.each(function(){$(this).css('width',optimalImageWidth+'px')})}
277function wplfAdjustStoreHours(){var maxSlotsRow=null;var maxSlotCount=0;$('.wplf-day-row.wplf-is-open').each(function(){var timeSlots=$(this).find('.wplf-time-slot');var slotCount=timeSlots.length;if(slotCount>maxSlotCount){maxSlotCount=slotCount;maxSlotsRow=$(this)}});if(maxSlotsRow){var totalWidth=32;var timeSlots=maxSlotsRow.find('.wplf-time-slot');timeSlots.each(function(i){totalWidth+=$(this).outerWidth();if(i<timeSlots.length-1){totalWidth+=5}});var rowWidth=$('.wplf-day-rows').width();var contentWidth=rowWidth-135;if(totalWidth<contentWidth){maxSlotsRow.closest('.wplf-day-rows').find('.wplf-day-row.wplf-is-open .wplf-time-group').removeClass('wplf-time-col')}else{maxSlotsRow.closest('.wplf-day-rows').find('.wplf-day-row.wplf-is-open .wplf-time-group').addClass('wplf-time-col')}}}
278function observeMapResize(mapContainerId,mapInstance){if(!mapContainerId||!mapInstance)return;const container=document.getElementById(mapContainerId);if(!container)return;const resizeObserver=new ResizeObserver(()=>{mapInstance.invalidateSize()});resizeObserver.observe(container)}
279function wplfShowPrompt(message){const $overlay=$('<div class="wplf-overlay-prompt"></div>');const $prompt=$(`
280            <div class="wplf-center-prompt">
281                <div class="wplf-prompt-content">
282                    <img class="wplf-prompt-icon" src="${wplf_params.wplf_url}/public/icons/warning-icon.svg">
283                    <p class="wplf-prompt-message">${message}</p>
284                    <button type="button" class="wplf-prompt-btn wplf-action-button">OK</button>
285                </div>
286            </div>
287        `);$('body').append($overlay,$prompt);setTimeout(()=>{$overlay.addClass('visible');$prompt.addClass('visible')},20);$prompt.find('.wplf-prompt-btn').on('click',function(){$overlay.removeClass('visible');$prompt.removeClass('visible');setTimeout(()=>{$overlay.remove();$prompt.remove()},300)})}
288function wplfInitUploadFields(){function previewImage(file,container,input,dt,replace=!1,isFeatured=!1){if(!file.type.startsWith("image/")){alert(file.name+" is not a valid image file!");return}
289let reader=new FileReader();reader.onload=function(e){if(replace)container.html("");const li=document.createElement("li");li.innerHTML=`
290	                <img src="${e.target.result}" />
291	                <div class="img-hover-actions">
292	                    <div class="wplf-remove-image"><span>Remove</span></div>
293	                </div>
294	            `;container.removeClass("wplf-d-none").append(li);if(isFeatured){$(".upload_featured_image_button").addClass("wplf-d-none")}
295$(li).find(".wplf-remove-image").on("click",function(){if(isFeatured){input.val("");container.html("").addClass("wplf-d-none");$(".upload_featured_image_button").removeClass("wplf-d-none")}else{for(let i=0;i<dt.items.length;i++){if(dt.items[i].getAsFile().name===file.name){dt.items.remove(i);break}}
296input[0].files=dt.files;$(li).remove();if(container.children("li").length===0){container.addClass("wplf-d-none");$(".clear_gallery").addClass("wplf-d-none")}}})};
296reader.readAsDataURL(file)}
297$(".upload_featured_image_button").on("click",function(e){if(!$(e.target).is("input[type=file]")){$(this).siblings(".featured_image").trigger("click")}});$(".featured_image").on("change",function(){if(this.files.length){previewImage(this.files[0],$(".featured_image_preview"),$(".featured_image"),null,!0,!0)}});$(".upload_featured_image_button").on("dragover",function(e){e.preventDefault();$(this).css("border-color","#0073aa")}).on("dragleave",function(){$(this).css("border-color","#C0C1C7")}).on("drop",function(e){e.preventDefault();$(this).css("border-color","#C0C1C7");let file=e.originalEvent.dataTransfer.files[0];if(file&&file.type.startsWith("image/")){$(".featured_image")[0].files=e.originalEvent.dataTransfer.files;previewImage(file,$(".featured_image_preview"),$(".featured_image"),null,!0,!0)}});$(".image_gallery").each(function(){const input=$(this);const container=$(".image_gallery_preview");let dt=new DataTransfer();$(".upload_image_gallery_button").on("click",function(e){if(!$(e.target).is("input[type=file]")){input.trigger("click")}});input.on("change",function(){container.html("");dt=new DataTransfer();for(let i=0;i<this.files.length;i++){dt.items.add(this.files[i]);previewImage(this.files[i],container,input,dt)}
298input[0].files=dt.files;if(dt.files.length>0){$(".clear_gallery").removeClass("wplf-d-none")}});$(".upload_image_gallery_button").on("dragover",function(e){e.preventDefault();$(this).css("border-color","#0073aa")}).on("dragleave",function(){$(this).css("border-color","#C0C1C7")}).on("drop",function(e){e.preventDefault();$(this).css("border-color","#C0C1C7");let files=e.originalEvent.dataTransfer.files;for(let i=0;i<files.length;i++){if(files[i].type.startsWith("image/")){dt.items.add(files[i]);previewImage(files[i],container,input,dt)}}
299input[0].files=dt.files;if(dt.files.length>0){$(".clear_gallery").removeClass("wplf-d-none")}});$(".clear_gallery").on("click",function(){input.val("");dt=new DataTransfer();container.html("").addClass("wplf-d-none");$(this).addClass("wplf-d-none")})})}
300wplfInitUploadFields();$('.marker_icon_set_btn').click(function(){$(this).closest('.wplf-submission-form').find('.marker_icon_box').css('display','flex');$('.wplf-overlay').show();if($('.custom-marker.marker-icon').length>0){var currentIcon=$(this).closest('.wplf-submission-form').find('.custom-marker.marker-icon').text()}else{var currentIcon=$(this).closest('.wplf-submission-form').find('.icon-preview .default-marker').text()}
301$('.fip-icons-container span.fip-box').removeClass('current-icon');$('.fip-icons-container span.fip-box[data-fip-value="'+currentIcon+'"]').addClass('current-icon')})
302$('.wplf-submission-form').each(function(){var form=$(this);var renderer=form.find('.svg_renderer');if(!renderer.length)return;$.getJSON(wplf_params.wplf_url+'admin/icons/google-icons.json',function(icons){var defaultIconStyle=wplf_params.default_icon_style||'filled';var classAttr='wplf-gg-icons material-icons';if(defaultIconStyle!=='filled')classAttr+='-'+defaultIconStyle;renderer.fontIconPicker({source:icons,emptyIcon:!1,autoClose:!1,searchPlaceholder:(wplf_translate&&wplf_translate.placeholder_icon_name)?wplf_translate.placeholder_icon_name:'Search icon',iconsPerPage:-1,iconGenerator:function(item){var iconColor=form.find('.set_marker_icon_color').val()||form.find('.set_marker_icon_color').data('default')||'#000';return'<i class="'+classAttr+'" style="display:flex;align-items:center;justify-content:center;height:100%;color:'+iconColor+'">'+item+'</i>'}})})});$(document).on('click','.save-icon-box',function(e){e.preventDefault();var form=$(this).closest('.wplf-submission-form');form.find('.custom-marker.marker-icon').remove();var selectedIcon=form.find('.svg_renderer').val()||'';var color=form.find('.set_marker_icon_color').val()||form.find('.set_marker_icon_color').data('default')||'#000';var bg=form.find('.icon_bg_color').val()||form.find('.icon_bg_color').data('default')||'transparent';var style=form.find('.icon_style').val()||form.find('input[name="icon_style"]').val()||(wplf_params&&wplf_params.default_icon_style)||'filled';var size=form.find('.icon_size').val()||40;var preview=form.find('.icon-preview');preview.find('div.custom-marker').remove();preview.find('i.default-marker').remove();var classAttr='material-icons'+(style!=='filled'?'-'+style:'');var inlineStyle='color:'+color+';background-color:'+bg+';font-size:'+size+'px;line-height:1;display:inline-flex;align-items:center;justify-content:center;';preview.append('<i class="'+classAttr+' default-marker" style="'+inlineStyle+'">'+selectedIcon+'</i>');form.find('input[name="marker_image_icon"]').val(selectedIcon);form.find('input[name="marker_icon_color"]').val(color);form.find('input[name="icon_bg_color"]').val(bg);form.find('input[name="icon_style"]').val(style);form.find('input[name="icon_size"]').val(size);form.find('img.custom-marker').remove();form.find('.marker_image').val('');form.find('.marker_icon_box, .wplf-overlay').hide()});$(document).on('click','.close-icon-box',function(e){e.preventDefault();var form=$(this).closest('.wplf-submission-form');form.find('.marker_icon_box, .wplf-overlay').hide();form.find('.marker_icon_box .fip-icon-cancel').trigger('click')});$(".upload_marker_image_button").on("click",function(){$(this).closest(".marker_image_preview").find(".marker_image").trigger("click")});$(".marker_image").on("change",function(){var input=$(this);var wrapper=input.closest(".marker_image_preview");
302var container=wrapper.find(".icon-preview");var resetBtn=wrapper.next(".reset-icon");var form=$(this).closest('.wplf-submission-form');if(this.files.length){var file=this.files[0];if(!file.type.startsWith("image/")){alert(file.name+" is not a valid image file!");input.val("");return}
303var reader=new FileReader();reader.onload=function(e){container.find("div.custom-marker").remove();container.find("i.default-marker").hide();container.append(`<div class="custom-marker" style="background-image:url('${e.target.result}');"></div>`);resetBtn.removeClass("wplf-d-none")};reader.readAsDataURL(file);form.find('input[name="marker_image_icon"]').val('')}});$(".reset-icon span").on("click",function(){var resetWrapper=$(this).closest(".reset-icon");var previewWrapper=resetWrapper.prev(".marker_image_preview");var container=previewWrapper.find(".icon-preview");var input=previewWrapper.find(".marker_image");input.val("");container.find("div.custom-marker").remove();container.find("i.default-marker").show();resetWrapper.addClass("wplf-d-none")});$('.advanced-setting-toggle').click(function(){var form=$(this).closest('.wplf-submission-form');var accordionContent=form.find('.icon-advanced-setting');var toggleButton=$(this).find('.accordion-toggle');var isExpanded=toggleButton.attr('aria-expanded')==='true';accordionContent.slideToggle();toggleButton.attr('aria-expanded',!isExpanded);var imgSrc=isExpanded?'arrow-down-icon.svg':'arrow-up-icon.svg';toggleButton.find('img').attr('src',wplf_params.wplf_url+'admin/icons/'+imgSrc)});$('.wplf-color-picker .wplf-preview-color').each(function(){const previewBtn=$(this);const inputColor=previewBtn.siblings('input');const parentWrap=previewBtn.closest('.wplf-color-picker');const defVal=inputColor.data('default');const pickr=Pickr.create({el:previewBtn[0],theme:'nano',default:inputColor.val(),components:{preview:!0,opacity:!0,hue:!0,interaction:{hex:!0,rgba:!0,hsla:!0,input:!0,clear:!1,save:!1}}});let pcrButton,popupEl;function placePopup(){if(!popupEl)return;const wrapOff=parentWrap.offset();const wrapH=parentWrap.outerHeight();const popW=popupEl.outerWidth();const popH=popupEl.outerHeight();const win=$(window);const wTop=win.scrollTop();const wLeft=win.scrollLeft();const wH=win.height();const wW=win.width();const spaceBelow=(wrapOff.top-wTop)+wrapH;let top;if((wH-spaceBelow)>=popH){top=wrapOff.top+wrapH+4}else{top=wrapOff.top-popH-4}
304let left=wrapOff.left;if(left+popW>wLeft+wW-8){left=Math.max(wLeft+8,(wLeft+wW)-popW-8)}
305popupEl.css({position:'absolute',top:top,left:left,'box-shadow':'0 12px 28px rgba(0,0,0,0.4)','z-index':99999})}
306function injectHeader(p){const root=$(p.getRoot().app);if(root.find('.pcr-custom-head').length)return;const head=$(`
307                <div class="pcr-custom-head">
308                    <span class="pcr-title">${wplf_translate.color_picker}</span>
309                    <div class="pcr-head-actions">
310                        <button type="button" class="pcr-btn-reset" title="Reset">
311                            <svg width="16" height="16" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
312                                <path d="M13 3C8.03 3 4 7.03 4 12H1L4.89 15.89L4.96 16.03L9 12H6C6 8.13 9.13 5 13 5C16.87 5 20 8.13 20 12C20 15.87 16.87 19 13 19C11.07 19 9.32 18.21 8.06 16.94L6.64 18.36C8.27 19.99 10.51 21 13 21C17.97 21 22 16.97 22 12C22 7.03 17.97 3 13 3ZM12 8V13L16.28 15.54L17 14.33L13.5 12.25V8H12Z" fill="#28282D"/>
313                            </svg>
314                        </button>
315                    </div>
316                </div>
317            `);root.prepend(head);head.on('click','.pcr-btn-reset',()=>{inputColor.val(defVal).trigger('change');previewBtn.css('background',defVal);p.setColor(defVal)})}
318pickr.on('init',()=>{pcrButton=$(pickr.getRoot().button);const initial=pickr.getColor().toHEXA().toString();inputColor.val(initial);previewBtn.css('background-color',initial);pcrButton.css('background',initial);injectHeader(pickr)}).on('change',(color)=>{const selectedColor=color.toHEXA().toString();inputColor.val(selectedColor).trigger('change');previewBtn.css('background-color',selectedColor);if(!pcrButton)pcrButton=$(pickr.getRoot().button);pcrButton.css('background',selectedColor);pcrButton.css('--pcr-color',selectedColor);if(inputColor.attr('id')==='set_marker_icon_color'){$('.icon-box-list .
318wplf-gg-icons').css('color',selectedColor)}}).on('show',()=>{window.isColorPickerOpen=!0;popupEl=$(pickr.getRoot().app);setTimeout(placePopup,0);$(window).on('scroll.pickr resize.pickr',placePopup)}).on('hide',()=>{window.isColorPickerOpen=!1;$(window).off('scroll.pickr resize.pickr')});inputColor.on('input',function(){var iconColor=$(this).val();pickr.setColor(iconColor)})});$('.wplf-frontend-form').on('submit',function(e){let form=$(this);let valid=!0;let locationName=form.find('.location_name').val().trim();let latitude=form.find('.latitude').val().trim();let longitude=form.find('.longitude').val().trim();form.find('.hint-text.wplf-error-text').addClass('wplf-d-none');form.find('.form-control').removeClass('wplf-input-error');if(!locationName){valid=!1;form.find('.location_name').addClass('wplf-input-error');form.find('.location_name_message').removeClass('wplf-d-none');wplfShowPrompt(wplf_translate.msg_enter_location_name)}else if(!latitude||!longitude){valid=!1;wplfShowPrompt(wplf_translate.msg_location_missing)}
319if(!valid){e.preventDefault();e.stopPropagation()}});wplfAdjustGalleryImages();$(window).resize(wplfAdjustGalleryImages);wplfAdjustStoreHours();$(window).resize(wplfAdjustStoreHours);Fancybox.bind('[data-fancybox="wplf-gallery-item"]',{arrows:!0,Toolbar:{display:{left:[],middle:["prev","infobar","next"],right:["close"],}},on:{done:(fancybox)=>{fancybox.container.classList.add('wplf-custom-fancybox')}}});$('.wplf-single-image').click(function(){$(this).parent().find('.wplf-gallery-item[data-id="0"]').trigger('click')})
320$('.wplf-galleries img').click(function(){var imgDataId=$(this).data('id');$(this).closest('.wplf-detail-location').find('.wplf-gallery-item[data-id="'+imgDataId+'"]').trigger('click')});$('.wplf-single-tags li').click(function(){var url=$(this).find('a').attr('href');if(url){window.location.href=url}})
321$('.wplf-back-btn').click(function(){var parentEle=$(this).closest('.wplf-map-content');parentEle.find('.wplf-form-search').removeClass('wplf-d-none');parentEle.find('.wplf-location-list').addClass('wplf-d-none')})
322function adjustMargin(){const $header=$('[data-elementor-type="header"]');const $wrapper=$('.wplf-detail-location-template');if($header.length&&$wrapper.length){const headerHeight=$header.outerHeight()||0;$wrapper.css('margin-top',(headerHeight+25)+'px')}}
323adjustMargin();$(window).on('resize',adjustMargin);setTimeout(adjustMargin,1000);const $header=$('[data-elementor-type="header"]');if($header.length&&window.MutationObserver){const observer=new MutationObserver(adjustMargin);observer.observe($header[0],{attributes:!0,attributeFilter:['class']})}
324const wplfNotice=$('.wplf-notice');if(wplfNotice.length){setTimeout(function(){wplfNotice.fadeOut(600,function(){$(this).remove()})},3000)}
325function fetchSuggestions(query,contentId){if(currentRequestSuggestion!==null){currentRequestSuggestion.abort()}
326currentRequestSuggestion=$.ajax({url:wplf_params.ajax_url,type:'GET',dataType:'json',data:{action:'wplf_get_suggestions',q:query,nonce:wplf_params.nonce},success:function(response){var suggestionsContainer=$('#wplf-name-suggestions-'+contentId);suggestionsContainer.html('');if(response&&response.length>0){suggestionsContainer.removeClass('wplf-d-none');response.forEach(function(item){var suggestionItem=$('<div class="wplf-suggestion-item" data-id="'+item.id+'">'+item.text+'</div>');suggestionItem.on('click',function(){var locationName=$(this).text();$('#name_search-'+contentId).val(locationName);$('#wplf-content-'+contentId).find('.wplf-name-search-clear').removeClass('wplf-d-none');suggestionsContainer.addClass('wplf-d-none')});suggestionsContainer.append(suggestionItem)})}else{suggestionsContainer.addClass('wplf-d-none')}},complete:function(){currentRequestSuggestion=null}})}
327function performNameSearch(input,contentId){var locationName=input.val();if(locationName.length>0){loadLocations(userLat,userLng,contentId);$('#wplf-content-'+contentId).find('.wplf-form-search').addClass('wplf-d-none');$('#wplf-content-'+contentId).find('.wplf-location-list').removeClass('wplf-d-none');$('#wplf-content-'+contentId).find('.wplf-back-btn').removeClass('wplf-d-none')}}})(jQuery)

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.