https://calzadospitillos.com/cdn/shop/t/27/assets/store-availabili…?v=143808277969689938441789484493
1(function(){function normalizeSearch(s){return(s||"").toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/\s+/g," ").trim()}function haversineKm(lat1,lon1,lat2,lon2){var toRad=function(deg){return deg*Math.PI/180},R=6371,dLat=toRad(lat2-lat1),dLon=toRad(lon2-lon1),a=Math.sin(dLat/2)*Math.sin(dLat/2)+Math.cos(toRad(lat1))*Math.cos(toRad(lat2))*Math.sin(dLon/2)*Math.sin(dLon/2);return R*(2*Math.atan2(Math.sqrt(a),Math.sqrt(1-a)))}function initStoreAvailabilityDrawer(){var drawer=document.getElementById("store-availability-drawer");if(!drawer)return;var mapEl=document.getElementById("store-availability-map"),mapWrap=document.getElementById("store-availability-map-wrap"),mapFallback=document.getElementById("store-availability-map-fallback"),apiKey=(drawer.dataset.mapsKey||"").trim(),cardsWrap=document.getElementById("store-availability-cards"),cards=cardsWrap?Array.prototype.slice.call(cardsWrap.querySelectorAll(".store-availability-card")):[],form=document.getElementById("store-availability-search-form"),input=document.getElementById("store-availability-search-input"),clearBtn=document.getElementById("store-availability-search-clear"),noResults=document.getElementById("store-availability-no-results"),map=null,markers=[],cachedUserPos=null;function applyFilter(){var q=normalizeSearch(input?input.value:""),visibleCount=0;cards.forEach(function(card){var blob=normalizeSearch(card.getAttribute("data-store-search")||""),match=!q||blob.indexOf(q)!==-1;card.classList.toggle("store-availability-card--hidden",!match),match&&(visibleCount+=1)}),noResults&&(noResults.hidden=!q||visibleCount>0),clearBtn&&(clearBtn.hidden=!(input&&input.value||"").trim()),refreshMap()}function clearMarkers(){markers.forEach(function(m){m.setMap(null)}),markers=[]}function centerMapOnStoreCard(card){if(!(!map||typeof google=="undefined"||!google.maps)){var lat=parseFloat(card.getAttribute("data-lat")),lng=parseFloat(card.getAttribute("data-lng"));!isFinite(lat)||!isFinite(lng)||(map.panTo({lat:lat,lng:lng}),map.setZoom(14))}}function refreshMap(){if(!(!map||typeof google=="undefined"||!google.maps)){clearMarkers();var bounds=new google.maps.LatLngBounds,count=0;cards.forEach(function(card){if(!card.classList.contains("store-availability-card--hidden")){var lat=parseFloat(card.getAttribute("data-lat")),lng=parseFloat(card.getAttribute("data-lng"));if(!(!isFinite(lat)||!isFinite(lng))){var pos={lat:lat,lng:lng};bounds.extend(pos);var marker=new google.maps.Marker({map:map,position:pos});marker.addListener("click",function(){card.scrollIntoView({behavior:"smooth",block:"nearest"}),card.classList.add("store-availability-card--highlight"),window.setTimeout(function(){card.classList.remove("store-availability-card--highlight")},1600)}),markers.push(marker),count+=1}}}),count===0?(map.setCenter({lat:40.4167754,lng:-3.7037902}),map.setZoom(6)):count===1?(map.setCenter(bounds.getCenter()),map.setZoom(14)):map.fitBounds(bounds)}}function loadMapScript(cb){var src="https://maps.googleapis.com/maps/api/js?key="+encodeURIComponent(apiKey);if(typeof theme!="undefined"&&typeof theme.loadScriptOnce=="function")theme.loadScriptOnce(src,cb);else{var tag=document.createElement("script");tag.src=src,tag.onload=cb,document.head.appendChild(tag)}}function ensureMap(){if(!apiKey||!mapEl){mapFallback&&(mapFallback.hidden=!1);return}mapFallback&&(mapFallback.hidden=!0),map?(google.maps.event.trigger(map,"resize"),refreshMap()):loadMapScript(function(){map=new google.maps.Map(mapEl,{zoom:6,center:{lat:40.4167754,lng:-3.7037902},zoomControl:!0,mapTypeControl:!1,streetViewControl:!1,fullscreenControl:!1}),google.maps.event.addListenerOnce(map,"idle",refreshMap)})}function updateDistanceLabels(){if(cachedUserPos){var unit=(drawer.dataset.distanceUnit||"km").trim(),lang=document.documentElement.getAttribute("lang")||"es",fmt=new Intl.NumberFormat(lang,{minimumFractionDigits:2,maximumFractionDigits:2});cards.forEach(function(card){var el=card.querySelector("[data-store-distance]");if(el){var lat=parseFloat(card.getAttribute("data-lat")),lng=parseFloat(card.getAttribute("data-lng"));if(!(!isFinite(lat)||!isFinite(lng))){var km=haversineKm(cachedUserPos.lat,cachedUserPos.lng,lat,lng),label=fmt.format(km)+" "+unit;el.textContent=label,el.hidden=!1,el.setAttribute("aria-hidden","false"),el.setAttribute("aria-label",label)}}})}}function requestUserLocation(){if(navigator.geolocation){if(cachedUserPos){updateDistanceLabels();return}navigator.geolocation.getCurrentPosition(function(pos){cachedUserPos={lat:pos.coords.latitude,lng:pos.coords.longitude},updateDistanceLabels()},function(){},{enableHighAccuracy:!1,maximumAge:3e5,timeout:12e3})}}function onAfterOpen(){requestUserLocation(),window.setTimeout(function(){ensureMap(),map&&(google.maps.event.trigger(map,"resize"),refreshMap())},400)}drawer.addEventListener("theme-drawer:open",onAfterOpen),form&&form.addEventListener("submit",function(evt){evt.preventDefault(),applyFilter()}),clearBtn&&clearBtn.addEventListener("click",function(){input&&(input.value=""),applyFilter()}),input&&input.addEventListener("input",function(){clearBtn&&(clearBtn.hidden=!input.value.trim())}),!apiKey&&mapFallback&&mapWrap&&mapWrap.classList.add("store-availability-map-wrap--no-key"),cards.forEach(function(card){card.addEventListener("click",function(evt){var el=evt.target;el&&el.closest&&(el.closest("a, button, summary, label, input, select, textarea")||el.closest(".store-availability-card__details"))||centerMapOnStoreCard(card)})})}function boot(){customElements.whenDefined("theme-drawer").then(initStoreAvailabilityDrawer)}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",boot):boot()})(); 2//# sourceMappingURL=/cdn/shop/t/27/assets/store-availability-drawer.js.map?v=143808277969689938441789484493
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.