window.initScopeMaps=async function(e=document){var t=e.querySelectorAll(".gmap-container:not(.is-initialized)"),a="undefined"!=typeof GMapConfig&&GMapConfig.debug?"":".min";for(const r of t){const c=r.id,l=r.ownerDocument;try{const d=await MapLoader.load(c,e);if("undefined"==typeof google)continue;r.classList.add("is-initialized");let i;switch(d.mode){case"stories":await MapLoader.loadScript(d.uri+`/js/maps/modules/MapModuleStories${a}.js`),i=new window.MapModuleStories(r,d),await i.init(),i.renderStories();break;case"locations":case"search":await MapLoader.loadScript(d.uri+`/js/maps/modules/MapModuleLocations${a}.js`),i=new window.MapModuleLocations(r,d),await i.init(),d.kml?await i.loadKml(d.kml):d.csvData&&(i.setData(d.csvData),d.csv_path&&i.processGeocodingQueue(d.csv_path));const u=l.getElementById("reset-map-"+c)||l.querySelector(".reset-btn");u&&u.addEventListener("click",e=>{e.preventDefault();const t=l.getElementById("location-search-form-"+c);t&&t.reset(),i.reset(),i.renderLocations(i.allLocations)});const p=l.getElementById("location-search-form-"+c),m=l.getElementById("location-input-"+c);if(m&&google.maps.places){const f=new google.maps.places.Autocomplete(m,{types:["geocode"],componentRestrictions:{country:"DE"}});f.addListener("place_changed",()=>{var e=f.getPlace();if(e&&e.geometry){const n=l.getElementById("loc-radius-"+c)||l.getElementById("distance-"+c)||l.getElementById("duration-"+c);var t=parseInt(n?.value)||0,a=n?.getAttribute("data-filter-type")||(n?.id.startsWith("distance")?"distance":n?.id.startsWith("duration")?"duration":"radius"),o=l.querySelector(`input[name="show-routes-${c}"]`),o=!!o&&o.checked;i.searchAddress(e.geometry.location,t,a,o),i.scrollToMap()}}),m.addEventListener("keydown",e=>{"Enter"===e.key&&l.querySelector(".pac-item-selected")})}p&&p.addEventListener("submit",async e=>{e.preventDefault();const t=p.querySelector('input[type="text"], .location-input');var a=t?t.value.trim():"";const o=l.getElementById("loc-radius-"+c)||l.getElementById("distance-"+c)||l.getElementById("duration-"+c);var n=parseInt(o?.value)||0,s=o?.getAttribute("data-filter-type")||(o?.id.startsWith("distance")?"distance":o?.id.startsWith("duration")?"duration":"radius"),e=l.querySelector(`input[name="show-routes-${c}"]`),e=!!e&&e.checked;if(a&&!(a.length<2))try{await i.searchAddress(a,n,s,e),i.scrollToMap()}catch(e){}});const g=l.querySelectorAll(`#distance-${c}, #duration-`+c);g.forEach(s=>{var e=()=>{const t=s.value,e=s.closest("form");if(e){const a=s.closest(".map-filter-range"),o=(a||e).querySelectorAll(".tick");o.forEach(e=>e.classList.remove("active"));const n=Array.from(o).find(e=>e.classList.contains("v-"+t));n&&n.classList.add("active")}};s.addEventListener("input",e),s.addEventListener("change",e)});break;case"territory":if(d.territory&&0<d.territory.length){await MapLoader.loadScript(d.uri+`/js/maps/modules/MapModuleTerritory${a}.js`),i=new window.MapModuleTerritory(r,d),await i.init(),i.initTerritory(d.territory);const w=l.getElementById("location-input-"+c);if(w&&google.maps.places){let e={types:["address"],componentRestrictions:{country:"DE"}};if(d.bounds){const E=d.bounds.split("|");var o=E[0].split(","),n=E[1].split(",");const L=new google.maps.LatLngBounds({lat:parseFloat(o[0]),lng:parseFloat(o[1])},{lat:parseFloat(n[0]),lng:parseFloat(n[1])});e.bounds=L,e.strictBounds=!0;var s=L.getCenter();const M=new google.maps.Geocoder;M.geocode({location:s},(e,t)=>{"OK"!==t||!e[0]||(e=e[0].address_components.find(e=>e.types.includes("locality")))&&(d.detectedCity=e.long_name)})}const h=new google.maps.places.Autocomplete(w,e);w.addEventListener("keydown",e=>{"Enter"===e.key&&(document.querySelector(".pac-item-selected")||/\d+/.test(w.value)||(e.preventDefault(),setTimeout(()=>{w.focus();var e=w.value.length;w.setSelectionRange(e,e)},50)))},!0),h.addListener("place_changed",()=>{var e=h.getPlace();if(e&&e.address_components){let t="",a="";for(const o of e.address_components)o.types.includes("route")&&(t=o.long_name),o.types.includes("street_number")&&(a=o.long_name);""!==t&&setTimeout(()=>{var e;""===a&&(w.value.includes(t+" ")||(w.value=t+" ",w.focus(),e=w.value.length,w.setSelectionRange(e,e)))},10)}e&&e.geometry})}}const y=l.getElementById("reset-map-"+c)||l.querySelector(".reset-btn");y&&y.addEventListener("click",e=>{e.preventDefault();const t=l.getElementById("location-search-form-"+c);t&&t.reset(),i.reset()});const v=l.getElementById("location-search-form-"+c);v&&v.addEventListener("submit",async e=>{e.preventDefault();const t=v.querySelector('input[type="text"], .location-input'),a=t?t.value.trim():"";if(a&&!(a.length<2)){e=/\d+/.test(a);if(e)try{let e=a;const n=d.detectedCity||"";""===n||a.toLowerCase().includes(n.toLowerCase())||(e=a+", "+n);var o=await i.geocode(e);await i.searchAddress(o,0),i.scrollToMap()}catch(e){}else t&&(t.focus(),o=t.value.length,t.setSelectionRange(o,o))}})}i&&("true"!==d.show_tabs&&!0!==d.show_tabs||i.initTabs())}catch(e){}}},"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>window.initScopeMaps()):window.initScopeMaps();