class HotelsMap{#backToContinentBtn=document.getElementById("back-to-continent");#backToCountryBtn=document.getElementById("back-to-country");#backToWorldBtn=document.getElementById("back-to-world");circleDark="#000000";circleDarkStroke="#000000";circleLight="#FFFFFF";circleLightRadius=5;circleLightStroke="#999999";circleRadius=2;continentBounds=[];continentIsReady=0;continentsArr=[];#continents=[];countriesArr=[];countryBounds=[];countryIsReady=0;countryLayerPosition="national_park";#currentHotel;#currentAreaName="World";#currentContinent=null;#currentCountryId=0;#currentView=1;globalBounds=[[-170,-40],[170,40],];#hotelBar=document.getElementById("hotelbar");#hotelBarBookingInfo=document.getElementById("hotelbar-booking-info");#hotelBarPrice=document.getElementById('hotelbar-price');#layerColorDefault="#EBEBE4";#layerColorHover="#E4E4DA";#layerColorHoverContinentLevel="#94AB96";#layerColorOpacityDefault=1;#layerColorOpacityHoverContinentLevel=0.6;#layerColorSelected="#E4E4DA";map;maxCountryZoom=14;navControl;paddingZoom=0;POIsGeneralArr=[];#quickBooking=document.querySelector('#map-canvas .quick-booking');#sidebarElement=document.getElementById("sidebar");#viewAsListBtn=document.getElementById("list-view");#vars;constructor(vars){const me=this;me.#vars=vars;if(vars.continentId!=null&&vars.countryId==null&&vars.cityBounds==null){me.loadContinent();}
if(vars.continentId!=null&&vars.countryId!=null&&vars.cityBounds==null){me.loadCountry();}
if(vars.continentId!=null&&vars.countryId!=null&&vars.cityBounds!=null){me.loadCity();}
if(vars.themeId!=null||vars.dealId!=null){document.getElementById("map-canvas").classList.add("no-theme-no-deal");}
mapboxgl.accessToken="pk.eyJ1IjoiZGVzaWduaG90ZWxzIiwiYSI6ImNrZmNjY282ajE3cmEyeW9mNmQ1cXg4NTUifQ.OhKAJikUMl_xJ4CEWA-rHw";this.navControl=new mapboxgl.NavigationControl({showCompass:false,});this.map=new mapboxgl.Map({container:"map",style:"mapbox://styles/designhotels/cllkkj9sn01as01ph53hh1z56",});this.map.fitBounds(me.globalBounds,{duration:0});this.map.scrollZoom.disable();this.map.dragPan.disable();this.map.doubleClickZoom.disable();this.map.touchZoomRotate.disable();this.map.on("load",function(){if(me.#continents.length===0){fetch("/umbraco/api/map/GetContinents?"+
(vars.themeId!=null?"&themeId="+vars.themeId:"")+
(vars.dealId!=null?"&dealId="+vars.dealId:"")).then((response)=>response.json()).then((continentsData)=>{me.#continents=continentsData;me.#createContinentLayers();}).catch((error)=>{console.error("Error fetching continents data:",error);});}else{me.#createContinentLayers();}});document.getElementById("open-countries-list").addEventListener("click",function(){document.getElementById("open-countries-list").style.display="none";document.getElementById("countries-list").style.display="block";document.getElementById("close-countries-list").style.display="block";});document.getElementById("close-countries-list").addEventListener("click",function(){document.getElementById("close-countries-list").style.display="none";document.getElementById("countries-list").style.display="none";document.getElementById("open-countries-list").style.display="block";});me.#backToWorldBtn.addEventListener("click",function(){me.#trackBackToButton("World");me.#currentAreaName="World";me.#currentView=1;me.#currentContinent=null;me.map.scrollZoom.disable();me.map.dragPan.disable();me.map.removeControl(me.navControl);me.map.setMaxBounds(null);if(window.innerWidth<=640){me.map.dragPan.enable();}
me.#backToWorldBtn.style.display="none";me.#sidebarElement.style.display="none";me.#viewAsListBtn.style.display="none";me.#backToCountryBtn.style.display="none";me.continentsArr.forEach(function(continent){continent.getElement().style.display="block";});me.countriesArr.forEach(function(countryId){me.map.setLayoutProperty("country-primary-layer-"+countryId,"visibility","none");});me.POIsGeneralArr.forEach(function(continentId){me.map.setLayoutProperty("pois-primary-layer-"+continentId,"visibility","none");});me.map.fitBounds(me.globalBounds,{duration:0});});me.#backToContinentBtn.addEventListener("click",function(){me.#backToContinentClick();});document.getElementById("close-map").addEventListener("click",function(){document.getElementById("map-canvas").remove();});document.getElementById("hotelbar-close").addEventListener("click",function(){me.#closeHotelBar();});me.#hotelBarBookingInfo.querySelector("button").addEventListener("click",function(){me.#bookNowAction();});}#bookNowAction(){const me=this;const promo=document.getElementById('hotels-form').dataset.rates;let href=me.#currentHotel.roomsUrl+"?"+booking.getBookingUrlParams($(me.#quickBooking));if(promo!==""){href+="&promo="+promo;}
window.location.href=href;}#closeHotelBar(){this.#hotelBar.style.display="none";this.#updateSelectedPoi();}#updateSelectedPoi(hotelId){let countrySource=this.map.getSource('country-hotels-'+this.#currentCountryId);countrySource.setData({type:'FeatureCollection',features:countrySource._data.features.map((feature)=>{if(feature.properties.id===hotelId){feature.properties.status="selected";}else{feature.properties.status=null;}
return feature;})});}#clickHotel(feature){const me=this;if(me.#currentHotel?.id===feature.properties.id&&this.#hotelBar.style.display==="block"){me.#closeHotelBar();}else{me.#updateSelectedPoi(feature.properties.id);fetch("/umbraco/api/map/GetPdp?pdpId="+
feature.properties.id+
(me.#vars.themeId!=null?"&themeId="+me.#vars.themeId:"")+
(me.#vars.dealId!=null?"&dealId="+me.#vars.dealId:"")).then((response)=>response.json()).then((hotel)=>{me.#currentHotel=hotel;document.getElementById("hotelbar-swiper-wrapper").innerHTML="";if(hotel.images!=null){hotel.images.forEach(function(image){var slideElement=me.createCustomHTML("<img src='"+image+"' />");slideElement.classList.add("swiper-slide");document.getElementById("hotelbar-swiper-wrapper").appendChild(slideElement);});}
new Swiper("#hotelbar .swiper",{navigation:{nextEl:".swiper-button-next",prevEl:".swiper-button-prev",},});document.getElementById("hotelbar-name").innerHTML=hotel.name;document.getElementById("hotelbar-location").innerHTML=hotel.location;document.getElementById("hotelbar-description").innerHTML=hotel.description;document.getElementById("hotelbar-detail").querySelector("a").href=hotel.detailUrl;me.#loadHotelPrice();me.#hotelBar.style.display="block";}).catch((error)=>{console.error("Error fetching hotel data:",error);});}}
quickBookingUpdated(){if(this.#currentHotel&&this.#hotelBar.style.display!=='none'){this.#loadHotelPrice();}}#loadHotelPrice(){const me=this;me.#hotelBarBookingInfo.className="";me.#hotelBarBookingInfo.style.display="none";try{if(me.#quickBooking){let arrival;let departure;let duration;try{arrival=$.datepicker.parseDate("dd/mm/yy",document.querySelector('#map-canvas .quick-booking .from').innerHTML);departure=$.datepicker.parseDate("dd/mm/yy",document.querySelector('#map-canvas .quick-booking .to').innerHTML);duration=parseInt(Math.ceil((departure.getTime()-arrival.getTime())/(1000*3600*24)));}catch(e){arrival=undefined;departure=undefined;}
if(arrival&&departure){me.#hotelBarBookingInfo.classList.add("loading");me.#hotelBarBookingInfo.style.display="block";const roomElement=me.#quickBooking.querySelector(".room.open");const roomAdults=parseInt(roomElement.querySelector(".guest.adults > .number").innerHTML);const roomChildren=parseInt(roomElement.querySelector(".guest.children > .number").innerHTML);const roomChildrenAge=Array.from(roomElement.querySelectorAll(".guest.age.open > .number")).map(el=>parseInt(el.innerHTML));var Rooms=[];var Room={"ConnectorCustomData":{"CustomDataConnectorCode":"SABRE_SYNXIS","RoomTypeCode":""},"Paxes":[]}
for(let i=0;i<roomAdults;i++){Room.Paxes.push({Age:null,Type:"ADULT"});}
for(let i=0;i<roomChildren;i++){Room.Paxes.push({Age:roomChildrenAge[i],Type:"CHILD"});}
Rooms.push(Room);const dealRates=document.getElementById('hotels-form').dataset.rates;let customerCustomData=dealRates===''?{"CustomDataCode":"POSITIONER_DH_BEST_PRICE","CommunityRateCode":me.#currentHotel.communityRateCode,"DefaultRateCode":me.#currentHotel.defaultRateCode}:{"CustomDataCode":"POSITIONER_DH_BEST_PRICE_DEAL","Rates":dealRates.split(",")};const bestPriceRequest={"Request":{"ConnectorCode":"SABRE_SYNXIS","ConnectorCustomData":{"CustomDataConnectorCode":"SABRE_SYNXIS","ExactMatchOnly":false},"CustomerCustomData":customerCustomData,"Duration":Math.ceil((departure.getTime()-arrival.getTime())/(1000*3600*24)),"FromDate":booking.yymmdd(arrival),"ToDate":booking.yymmdd(departure),"HotelRefId":me.#currentHotel.synxisId,"Rooms":Rooms}};$.ajax({type:"POST",url:$('#hotels-form').attr('data-api-url'),dataType:"json",contentType:'application/json',data:JSON.stringify(bestPriceRequest),beforeSend:function(xhr){xhr.setRequestHeader('Authorization','Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI4M2UyMTMxNy1kNWRlLTRlZWEtYTE0OS0yYjM5MTIyNTRiODEiLCJ1bmlxdWVfbmFtZSI6IjIiLCJnaXZlbl9uYW1lIjoiQXBpVXNlciIsImVtYWlsIjoiYXBpdXNlckBsaW5rc3dpc3MuY29tIiwicm9sZSI6IkFQSV9VU0VSIiwibmJmIjoxNTgxNjkxODQwLCJleHAiOjE1ODE2OTU0NDAsImlhdCI6MTU4MTY5MTg0MCwiaXNzIjoiTGlua1N3aXNzIElDVCBTb2x1dGlvbnMgU2FnbCAtIEp1cGl0ZXIiLCJhdWQiOiJQb3NpdGlvbmVEZXNpZ25Ib3RlbHNKdXBpdGVyQXBpIn0.iCfkxxAUR9JjFw8CtjBprLRKufarGZcqAVAL7pICi90');},success:function(data){const rate=(data.LowestRate!==undefined&&data.LowestRate!==null)?data.LowestRate:data.Rate;if(rate===0){me.#hotelBarBookingInfo.classList.add("not-available");}else{fetch("/Umbraco/Api/CurrencyConverter/GetConversionRatio?fromCurrency="+me.#currentHotel.currency+"&toCurrency="+window.currencyConverter.getCurrency()).then(response=>response.text()).then(result=>{me.#hotelBarPrice.innerHTML=Math.round((parseFloat(result)*rate)/duration);}).catch(error=>console.log('error',error));}
me.#hotelBarBookingInfo.classList.remove("loading");},error:function(xhr,status,error){console.log(error)}})}}}catch(error){console.error(error);}}
createCustomHTML(html){var el=document.createElement("div");el.innerHTML=html;return el;}
findBounds(bounds){const me=this;let minLng=Infinity;let maxLng=-Infinity;let minLat=Infinity;let maxLat=-Infinity;bounds.forEach((coordinates)=>{if(Array.isArray(coordinates[0][0])){const innerBounds=me.findBounds(coordinates);minLng=Math.min(minLng,innerBounds[0][0]);maxLng=Math.max(maxLng,innerBounds[1][0]);minLat=Math.min(minLat,innerBounds[0][1]);maxLat=Math.max(maxLat,innerBounds[1][1]);}else{coordinates.forEach(([lng,lat])=>{minLng=Math.min(minLng,lng);maxLng=Math.max(maxLng,lng);minLat=Math.min(minLat,lat);maxLat=Math.max(maxLat,lat);});}});if(isFinite(minLng)&&isFinite(maxLng)&&isFinite(minLat)&&isFinite(maxLat)){return[[minLng-me.paddingZoom,minLat-me.paddingZoom],[maxLng+me.paddingZoom,maxLat+me.paddingZoom],];}else{return this.globalBounds;}}#createContinentLayers(){const me=this;me.#continents.forEach(function(continent){const continentMarker=new mapboxgl.Marker({id:continent.id,element:me.createCustomHTML("<div>"+continent.name+"<span>"+continent.itemsNr+"</span></div>"),anchor:"bottom",}).setLngLat(continent.coordinates).addTo(me.map);continentMarker._element.id="continent-marker-"+continent.id;var markerElement=continentMarker.getElement();markerElement.classList.add("continent-marker");me.continentsArr.push(continentMarker);if(window.innerWidth<=640){me.map.dragPan.enable();}
continentMarker.getElement().addEventListener("click",function(){me.#continentClick(continent);});me.continentIsReady=1;});}#createCountriesLayers(){const me=this;fetch("/umbraco/api/map/GetPois?continentId="+
me.#currentContinent.id+
(me.#vars.themeId!=null?"&themeId="+me.#vars.themeId:"")+
(me.#vars.dealId!=null?"&dealId="+me.#vars.dealId:"")).then((response)=>response.json()).then((poisData)=>{if(me.#currentContinent.bounds!==null){me.continentBounds=window.innerWidth<=640?me.#currentContinent.boundsMobile!=null?me.#currentContinent.boundsMobile:me.#currentContinent.bounds:me.#currentContinent.bounds;}else{var countriesInContinentBounds=me.#currentContinent.countries.filter(function(feature){return feature;}).map(function(feature){return feature.geometry.coordinates;});me.continentBounds=me.findBounds(countriesInContinentBounds);}
me.map.fitBounds(me.continentBounds,{duration:0,});me.map.scrollZoom.enable();me.map.touchZoomRotate.enable();me.map.dragPan.enable();me.map.setMaxBounds(me.continentBounds);me.map.addControl(me.navControl,"bottom-right");me.#currentContinent.countries.forEach(function(country){var countryCode=country.properties.country;var countryPrimaryLayerId="country-primary-layer-"+countryCode;var countryDetailLayerId="country-detail-layer-"+countryCode;var poisSecondaryLayerId="POIs-secondary-layer-"+countryCode;var countryPrimaryLayerIdSource=countryPrimaryLayerId+"-source";if(!(me.map.getLayer(countryPrimaryLayerId)&&me.map.getSource(countryPrimaryLayerIdSource))){me.map.addSource(countryPrimaryLayerIdSource,{type:"geojson",data:{type:"FeatureCollection",features:me.#currentContinent.countries.filter(function(feature){return feature.properties.country===countryCode;}),},});me.map.addLayer({id:countryPrimaryLayerId,type:"fill",source:countryPrimaryLayerIdSource,paint:{"fill-color":me.#layerColorDefault},},me.countryLayerPosition);me.map.addLayer({id:countryDetailLayerId,type:"fill",source:countryPrimaryLayerIdSource,paint:{"fill-color":me.#layerColorSelected},},me.countryLayerPosition);me.map.setLayoutProperty(countryDetailLayerId,"visibility","none");me.map.addSource(poisSecondaryLayerId,{type:"geojson",data:{type:"FeatureCollection",features:poisData.filter(function(feature){return feature.properties.country===countryCode;}),},});me.map.addLayer({id:poisSecondaryLayerId,type:"circle",source:poisSecondaryLayerId,paint:{"circle-color":me.circleLight,"circle-stroke-color":me.circleLightStroke,"circle-radius":me.circleLightRadius,},});me.map.setPaintProperty(poisSecondaryLayerId,"circle-stroke-width",2);me.map.setLayoutProperty(poisSecondaryLayerId,"visibility","none");function onMouseEnterOnPrimary(){if(me.#currentView===2){me.map.setPaintProperty(countryPrimaryLayerId,"fill-color",me.#layerColorHoverContinentLevel);me.map.setPaintProperty(countryPrimaryLayerId,"fill-opacity",me.#layerColorOpacityHoverContinentLevel);}else{me.map.setPaintProperty(countryPrimaryLayerId,"fill-color",me.#layerColorHover);}
me.map.getCanvas().style.cursor="pointer";}
function onMouseLeaveOnPrimary(){me.map.setPaintProperty(countryPrimaryLayerId,"fill-color",me.#layerColorDefault);me.map.setPaintProperty(countryPrimaryLayerId,"fill-opacity",me.#layerColorOpacityDefault);me.map.getCanvas().style.cursor="auto";}
me.map.on("mouseenter",countryPrimaryLayerId,function(){onMouseEnterOnPrimary();});me.map.on("mouseleave",countryPrimaryLayerId,function(){onMouseLeaveOnPrimary();});me.map.on("click",countryPrimaryLayerId,function(){setTimeout(function(){me.#countryClick(country,true)},0);});var countryElement=me.createCustomHTML("<div><span>"+country.properties.name+"</span><span id='"+countryCode+"-pois-nr'>"+"-"+"</span></div>");countryElement.id="list-country-"+countryCode;document.getElementById("countries-list").appendChild(countryElement);countryElement.addEventListener("mouseenter",function(){onMouseEnterOnPrimary();});countryElement.addEventListener("mouseleave",function(){onMouseLeaveOnPrimary();});countryElement.addEventListener("click",function(){me.#countryClick(country,true)});}else{me.map.setLayoutProperty(countryPrimaryLayerId,"visibility","visible");document.getElementById("list-country-"+countryCode).style.display="block";}
me.countriesArr.push(countryCode);});var poisPrimaryLayerId="pois-primary-layer-"+me.#currentContinent.id;if(!(me.map.getLayer(poisPrimaryLayerId)&&me.map.getSource(poisPrimaryLayerId))){me.map.addSource(poisPrimaryLayerId,{type:"geojson",data:{type:"FeatureCollection",features:poisData,},});me.map.addLayer({id:poisPrimaryLayerId,type:"circle",source:poisPrimaryLayerId,paint:{"circle-color":me.circleDark,"circle-stroke-color":me.circleDarkStroke,"circle-radius":me.circleRadius,},});var countryCounts={};poisData.forEach((POI)=>{var country=POI.properties.country;if(countryCounts.hasOwnProperty(country)){countryCounts[country]++;}else{countryCounts[country]=1;}
var countsArray=Object.entries(countryCounts);countsArray.forEach(function(country){let countryPoisNr=document.getElementById(country[0]+"-pois-nr");if(countryPoisNr!=null){countryPoisNr.innerHTML=country[1];}});});}else{me.map.setLayoutProperty(poisPrimaryLayerId,"visibility","visible");}
me.POIsGeneralArr.push(me.#currentContinent.id);me.countryIsReady=1;});}
loadContinent(){const me=this;me.#currentView=2;document.getElementById("map-loader").style.opacity="0";var intervalContinent=setInterval(function(){if(me.continentIsReady===1){clearInterval(intervalContinent);me.#continentClick(me.#continents.find(continent=>continent.id===me.#vars.continentId),false);}},250);var intervalVisibility=setInterval(function(){if(me.continentIsReady===1){clearInterval(intervalVisibility);document.getElementById("map-loader").style.opacity="1";}},250);}
loadCountry(){const me=this;me.#currentView=3;document.getElementById("map-loader").style.opacity="0";var intervalContinent=setInterval(function(){if(me.continentIsReady===1){clearInterval(intervalContinent);me.#continentClick(me.#continents.find(continent=>continent.id===me.#vars.continentId),false);}},250);var intervalCountry=setInterval(function(){if(me.countryIsReady===1){clearInterval(intervalCountry);me.#countryClick(me.#currentContinent.countries.find(country=>country.properties.country===me.#vars.countryId),false);}},250);var intervalVisibility=setInterval(function(){if(me.continentIsReady===1&&me.countryIsReady===1){clearInterval(intervalVisibility);document.getElementById("map-loader").style.opacity="1";}},250);}#setCurrentContinent(continentId){const me=this;if(me.continentIsReady===1){me.#continentClick(me.#continents.find(continent=>continent.id===continentId),false);}else{setTimeout(function(){me.#setCurrentContinent(continentId)},250);}}
loadCity(){const me=this;me.#currentView=3;document.getElementById("map-loader").style.opacity="0";me.#setCurrentContinent(me.#vars.continentId);var intervalCountry=setInterval(function(){if(me.countryIsReady===1){clearInterval(intervalCountry);me.#countryClick(me.#currentContinent.countries.find(country=>country.properties.country===me.#vars.countryId),false);me.map.fitBounds(window.innerWidth<=640?(me.#vars.cityBoundsMobile!=null?me.#vars.cityBoundsMobile:me.#vars.cityBounds):me.#vars.cityBounds,{duration:0,});}},250);var intervalVisibility=setInterval(function(){if(me.continentIsReady===1&&me.countryIsReady===1){clearInterval(intervalVisibility);document.getElementById("map-loader").style.opacity="1";}},250);}#backToCountryClick(){const me=this;me.#trackBackToButton(me.#currentAreaName);me.map.fitBounds(me.countryBounds,{duration:0,});}#backToContinentClick(){const me=this;me.#currentView=2;me.#currentCountryId=0;me.#backToWorldBtn.style.display="block";me.#backToContinentBtn.style.display="none";me.#sidebarElement.style.display="block";me.#hotelBar.style.display="none";me.#backToCountryBtn.style.display="none";document.getElementById("map-quick-booking").style.display="none";me.countriesArr.forEach(function(countryId){me.map.setLayoutProperty("country-primary-layer-"+countryId,"visibility","visible");me.map.setLayoutProperty("country-detail-layer-"+countryId,"visibility","none");me.map.setLayoutProperty("POIs-secondary-layer-"+countryId,"visibility","none");if(me.map.getLayer("clusters-"+countryId)){me.map.setLayoutProperty("clusters-"+countryId,"visibility","none");}
if(me.map.getLayer("cluster-count-"+countryId)){me.map.setLayoutProperty("cluster-count-"+countryId,"visibility","none");}
if(me.map.getLayer("unclustered-point-"+countryId)){me.map.setLayoutProperty("unclustered-point-"+countryId,"visibility","none");}});me.POIsGeneralArr.forEach(function(continentId){let layerVisibility="none";if(continentId===me.#currentContinent.id){layerVisibility="visible";}
me.map.setLayoutProperty("pois-primary-layer-"+continentId,"visibility",layerVisibility);});me.map.scrollZoom.disable();me.map.dragPan.disable();me.map.removeControl(me.navControl);me.map.setMaxBounds(null);me.map.setMinZoom(null);me.map.setMaxZoom(null);me.map.fitBounds(me.continentBounds,{duration:0,});me.#trackBackToButton(me.#currentContinent.name)
me.#continentClick(me.#continents.find(continent=>continent.id===me.#currentContinent.id),false);}#viewAsListClick(listBaseUrl){const bookingUrlParams=booking.getBookingUrlParams($(this.#quickBooking));window.location.href=bookingUrlParams?`${listBaseUrl}?${bookingUrlParams}`:listBaseUrl;}#continentClick(continent,byHuman=true){const me=this;if(byHuman){me.#trackDestinationClick(me.#currentAreaName,continent.name);}
me.#currentView=2;if(window.innerWidth<=640){me.map.dragPan.disable();}
me.#backToWorldBtn.style.display="block";me.#sidebarElement.style.display="block";me.#viewAsListBtn.style.display="block";me.#viewAsListBtn.addEventListener("click",function(){me.#viewAsListClick(continent.listUrl);});me.continentsArr.forEach(function(continent){continent.getElement().style.display="none";});var countriesList=document.querySelectorAll("#countries-list > div");for(var i=0;i<countriesList.length;i++){countriesList[i].style.display="none";}
me.#currentContinent=continent;me.#currentAreaName=continent.name;if(!me.#currentContinent.countries){fetch("/umbraco/api/map/GetCountries?continentId="+
continent.id+
(me.#vars.themeId!=null?"&themeId="+me.#vars.themeId:"")+
(me.#vars.dealId!=null?"&dealId="+me.#vars.dealId:"")).then((response)=>response.json()).then((countriesData)=>{me.#currentContinent.countries=countriesData;me.#createCountriesLayers();}).catch((error)=>{console.error("Error fetching countries data:",error);});}else{me.#createCountriesLayers();}}#countryClick(country,byHuman=true){const me=this;if(byHuman){me.#trackDestinationClick(me.#currentAreaName,country.properties.name);}
me.#currentView=3;me.#currentCountryId=country.properties.country;me.#currentAreaName=country.properties.name;me.countryBounds=null;me.map.scrollZoom.disable();me.map.dragPan.disable();me.map.removeControl(me.navControl);me.map.setMaxBounds(null);me.map.setMinZoom(null);me.map.setMaxZoom(null);me.map.fitBounds(me.globalBounds,{duration:0,});me.#backToContinentBtn.textContent=me.#currentContinent.name;me.#backToWorldBtn.style.display="none";me.#backToContinentBtn.style.display="block";me.#sidebarElement.style.display="none";me.#hotelBar.style.display="none";document.getElementById("map-quick-booking").style.display="block";me.countriesArr.forEach(function(countryId){me.map.setLayoutProperty("country-primary-layer-"+countryId,"visibility",countryId===country.properties.country?"none":"visible");me.map.setLayoutProperty("country-detail-layer-"+countryId,"visibility",countryId===country.properties.country?"visible":"none");me.map.setLayoutProperty("POIs-secondary-layer-"+countryId,"visibility",countryId===country.properties.country?"none":"visible");if(me.map.getLayer("clusters-"+countryId)){me.map.setLayoutProperty("clusters-"+countryId,"visibility","none");}
if(me.map.getLayer("cluster-count-"+countryId)){me.map.setLayoutProperty("cluster-count-"+countryId,"visibility","none");}
if(me.map.getLayer("unclustered-point-"+countryId)){me.map.setLayoutProperty("unclustered-point-"+countryId,"visibility","none");}});me.POIsGeneralArr.forEach(function(continentId){me.map.setLayoutProperty("pois-primary-layer-"+continentId,"visibility","none");});var countryCoordinates=country.geometry.coordinates;if(country.properties.bounds!==null){me.countryBounds=window.innerWidth<=640?country.properties.boundsMobile!=null?country.properties.boundsMobile:country.properties.bounds:country.properties.bounds;}else{me.countryBounds=me.findBounds(countryCoordinates);}
me.map.fitBounds(me.countryBounds,{duration:0,});me.map.scrollZoom.enable();me.map.touchZoomRotate.enable();me.map.dragPan.enable();me.map.setMaxBounds(me.countryBounds);me.map.addControl(me.navControl,"bottom-right");var currentZoom=me.map.getZoom();me.map.setMinZoom(currentZoom);me.map.setMaxZoom(me.maxCountryZoom);me.#backToCountryBtn.style.display="none";me.#backToContinentBtn.style.display="block";me.#backToCountryBtn.addEventListener("click",function(){me.#backToCountryClick();});me.map.on("zoom",function(){if(me.#currentCountryId===country.properties.country){if(me.map.getZoom()===currentZoom){me.#backToCountryBtn.style.display="none";me.#backToContinentBtn.style.display="block";}else{me.#backToContinentBtn.style.display="none";me.#backToCountryBtn.textContent=me.#backToCountryBtn.getAttribute("data-text-content").replace("{1}",country.properties.name);me.#backToCountryBtn.style.display="block";}}});fetch("/umbraco/api/map/GetPois?continentId="+
me.#currentContinent.id+
(me.#vars.themeId!=null?"&themeId="+me.#vars.themeId:"")+
(me.#vars.dealId!=null?"&dealId="+me.#vars.dealId:"")).then((response)=>response.json()).then((poisData)=>{me.#viewAsListBtn.addEventListener("click",function(){me.#viewAsListClick(country.properties.listUrl)});if(!(me.map.getLayer("clusters-"+country.properties.country)&&me.map.getSource("country-hotels-"+country.properties.country))){me.map.addSource("country-hotels-"+country.properties.country,{type:"geojson",data:{type:"FeatureCollection",features:poisData.filter(function(POI){return POI.properties.country===country.properties.country;}),},cluster:true,clusterRadius:30,});me.map.addLayer({id:"clusters-"+country.properties.country,type:"circle",source:"country-hotels-"+country.properties.country,filter:["has","point_count"],paint:{"circle-color":["step",["get","point_count"],me.circleDark,20,me.circleDark],"circle-radius":["step",["get","point_count"],18,18,18],},});me.map.addLayer({id:"cluster-count-"+country.properties.country,type:"symbol",source:"country-hotels-"+country.properties.country,filter:["has","point_count"],layout:{"text-field":["get","point_count_abbreviated"],"text-font":["Arial Unicode MS Bold"],"text-size":12,},paint:{"text-color":me.circleLight,},});me.map.addLayer({id:"unclustered-point-"+country.properties.country,type:"circle",source:"country-hotels-"+country.properties.country,filter:["!",["has","point_count"]],paint:{"circle-radius":7,'circle-color':['match',['get','status'],'selected','#94ab96',me.circleDark]}});me.map.on("click","clusters-"+country.properties.country,(e)=>{const features=me.map.queryRenderedFeatures(e.point,{layers:["clusters-"+country.properties.country],});const clusterId=features[0].properties.cluster_id;me.map.getSource("country-hotels-"+country.properties.country).getClusterExpansionZoom(clusterId,(err,zoom)=>{if(err)return;me.map.easeTo({center:features[0].geometry.coordinates,zoom:zoom,});});});me.map.on("click","unclustered-point-"+country.properties.country,(e)=>{me.#clickHotel(e.features[0]);});me.map.on("mouseenter","clusters-"+country.properties.country,()=>{me.map.getCanvas().style.cursor="pointer";});me.map.on("mouseenter","unclustered-point-"+country.properties.country,()=>{me.map.getCanvas().style.cursor="pointer";});me.map.on("mouseleave","clusters-"+country.properties.country,()=>{me.map.getCanvas().style.cursor="";});me.map.on("mouseleave","unclustered-point-"+country.properties.country,()=>{me.map.getCanvas().style.cursor="";});}else{me.map.setLayoutProperty("clusters-"+country.properties.country,"visibility","visible");me.map.setLayoutProperty("cluster-count-"+country.properties.country,"visibility","visible");me.map.setLayoutProperty("unclustered-point-"+country.properties.country,"visibility","visible");}});}#trackBackToButton(newAreaName){window.dataLayer=window.dataLayer||[];window.dataLayer.push({ecommerce:null});window.dataLayer.push({'event':'backMap','eventName':'map_destination_back','section':newAreaName,'previous_section':this.#currentAreaName});}#trackDestinationClick(currentAreaName,nextAreaName){window.dataLayer=window.dataLayer||[];window.dataLayer.push({ecommerce:null});window.dataLayer.push({'event':'mapDestinationClick','eventName':'map_destination_click','section':currentAreaName+' > '+nextAreaName});}};;var mapboxFull={init:function(vars){$.get("/sources/mapbox-full.html",function(data){$("body").append(data);$("#map-canvas").show();window.mapObject=new HotelsMap({continentId:vars.continentId!==undefined&&vars.continentId!==null?parseInt(vars.continentId):null,countryId:vars.countryId!==undefined&&vars.countryId!==null?parseInt(vars.countryId):null,cityBounds:vars.cityBounds!=undefined?vars.cityBounds:null,cityBoundsMobile:vars.cityBoundsMobile!=undefined?vars.cityBoundsMobile:null,themeId:vars.themeId!=undefined?vars.themeId:null,dealId:vars.dealId!=undefined?vars.dealId:null,});const quickBooking=document.querySelector('#search-bar .quick-booking');const mapQuickBooking=document.querySelector('#map-quick-booking .quick-booking');if(quickBooking){const qbFrom=quickBooking.querySelector('.from');const qbTo=quickBooking.querySelector('.to');if(qbFrom.innerHTML!==qbFrom.dataset.placeholder&&qbTo.innerHTML!==qbTo.dataset.placeholder){mapQuickBooking.dataset.arrival=qbFrom.innerHTML;mapQuickBooking.dataset.departure=qbTo.innerHTML;mapQuickBooking.dataset.guests=quickBooking.dataset.guests;}}
booking.default($("#map-quick-booking .quick-booking"));booking.openPnls("#map-quick-booking .quick-booking");});},};const mapBtnElements=document.querySelectorAll(".map-btn-icon");mapBtnElements.forEach(function(element){element.addEventListener("click",function(event){var sender=event.target;mapboxFull.init({continentId:sender.getAttribute("continent-id")??null,countryId:sender.getAttribute("country-id")??null,cityBounds:JSON.parse(sender.getAttribute("bounds"))??null,cityBoundsMobile:JSON.parse(sender.getAttribute("bounds-mobile"))??null,themeId:sender.getAttribute("theme-id")??null,dealId:sender.getAttribute("deal-id")??null,});});});;;