(async()=>{const{loadScript:e,hideElement:t}=await import(window.theme.modules.utils);var s=await import(window.theme.modules.baseComponent);customElements.define("google-map",class extends s.default{elements={styleJSON:"[data-style-json]"};willLoad=!0;render(){this.mapStyle=JSON.parse(this.$styleJSON.textContent)}onAuthError(){this.willLoad=!1,t(this)}async onIntersect(e){e&&!this.map&&this.willLoad&&await this._initMap()}async _initMap(){window.google?.maps?.Map||await e(`https://maps.googleapis.com/maps/api/js?key=${this.getAttribute("api-key")}`),this.geo=new window.google.maps.Geocoder,this.geo.geocode({address:this.getAttribute("address")},(e,t)=>{if(console.log(t),t===window.google.maps.GeocoderStatus.OK){const s=e[0].geometry.location;this._renderMap(s.lat(),s.lng())}else console.error(t)})}_renderMap(e,t){this.map=new window.google.maps.Map(this,{center:{lat:e,lng:t},zoom:12,disableDefaultUI:!0,styles:this.mapStyle}),window.google.maps.event.addListenerOnce(this.map,"idle",()=>{this.setAttribute("loaded","")}),this._setMarker()}_setMarker(){var e=``;const t=new window.google.maps.Marker({position:this.map.getCenter(),map:this.map,icon:{url:"data:image/svg+xml;charset=UTF-8,"+encodeURIComponent(e),scaledSize:new window.google.maps.Size(30,30)}});t.addListener("click",()=>{this.hasAttribute("directions-url")&&window.open(this.getAttribute("directions-url"),"_blank")})}})})();