"use strict";function getOfferSearchViewModel(){offerSearchViewModel=offerSearchViewModel}function filterOnSalesUnits(n){offerSearchViewModel.setValidSalesUnitIds(n)}function passOfferData(n){offerSearchViewModel.setOfferData(n)}function selectSalesUnit(n){var t=offerSearchViewModel.allSalesUnits.filter(function(t){return t.Id===n}),i;t.length>0&&(offerSearchViewModel.selectSalesUnit(t[0]),i=offerSearchViewModel.selectedSalesUnit(),i.IsShowHouse?($.magnificPopup.open({items:{src:"#modal-showhousewindow",type:"inline"}}),chopstickBlazy()):$.magnificPopup.open({items:{src:"#modal-infowindow",type:"inline"}}))}var Scripts,offerSearchViewModel;(function(n){var t;(function(n){var t;(function(n){var i=function(){function n(n,t,i,r,u,f,e,o,s,h,c,l){this.ID=n;this.Description=t;this.Address=i;this.Longitude=r;this.Latitude=u;this.ImageSrc=f;this.ImageAlt=e;this.URL=o;this.Name=s;this.EventLocationType=h;this.EventsTitle=c;this.Events=l}return n}(),t;n.ShowHouse=i;t=function(){function n(n,t,i,r,u){this.ID=n;this.DateInformation=t;this.TimeInformation=i;this.Type=r;this.IsRecurring=u}return n}();n.ShowhouseEvent=t})(t=n.Offer||(n.Offer={}))})(t=n.Components||(n.Components={}))})(Scripts||(Scripts={})),function(n){var t;(function(n){var t;(function(n){var i=function(){function n(n,t,i,r,u,f,e,o,s,h,c,l,a,v,y,p,w,b,k,d,g,nt){this.Id=n;this.Title=t;this.CommercialType=i;this.ImageSrc=r;this.HasOption=u;this.IsCasco=f;this.Price=e;this.CascoPrice=o;this.DisplayPrice=s;this.SalesUnitBrochureLink=h;this.DescriptionItems=c;this.SalesUnitTypeLogo=l;this.SalesUnitHeadType=a;this.SalesUnitHeadTypeId=v;this.NumberOfBedrooms=y;this.IsShowHouse=p;this.ShowHouseID=w;this.Reference=b;this.TypeOfInterest=k;this.LivableArea=d;this.Availability=g;this.InvestProjectUrl=nt;this.Name=ko.observable(t);this.Levels=ko.observableArray()}return n}(),t;n.SalesUnit=i;t=function(){function n(n,t,i,r,u,f,e,o,s,h,c,l,a,v,y,p,w,b,k,d,g,nt,tt,it,rt,ut,ft,et,ot,st,ht,ct,lt,at,vt,yt,pt,wt,bt,kt,dt,gt,ni,ti,ii,ri,ui,fi,ei,oi,si,hi,ci,li,ai,vi,yi,pi){this.Id=n;this.Title=t;this.CommercialType=i;this.ImageSrc=r;this.HasOption=u;this.IsCasco=f;this.Price=e;this.CascoPrice=o;this.DisplayPrice=s;this.SalesUnitBrochureLink=h;this.DescriptionItems=c;this.SalesUnitTypeLogo=l;this.SalesUnitHeadType=a;this.SalesUnitHeadTypeId=v;this.NumberOfBedrooms=y;this.IsShowHouse=p;this.ShowHouseID=w;this.Reference=b;this.TypeOfInterest=k;this.LivableArea=d;this.Availability=g;this.InvestProjectUrl=nt;this.NumberOfBathrooms=tt;this.HasGarden=it;this.GardenDirection=rt;this.HasTerace=ut;this.HasGarage=ft;this.GarageType=et;this.HasGarageBox=ot;this.GarageBoxType=st;this.HasAttic=ht;this.AtticType=ct;this.HasParkingPlace=lt;this.ParkingPlaceType=at;this.HasCarport=vt;this.HasBycicleShed=yt;this.HasShed=pt;this.BuildableArea=wt;this.GroundArea=bt;this.BedRoom1Area=kt;this.BedRoom2Area=dt;this.BedRoom3Area=gt;this.BedRoom4Area=ni;this.BathRoom1Area=ti;this.BathRoom2Area=ii;this.BathRoom3Area=ri;this.KitchenArea=ui;this.LivingRoomArea=fi;this.HallArea=ei;this.CarportArea=oi;this.AtticArea=si;this.TeraceArea=hi;this.GardenArea=ci;this.ShowEnergy=li;this.EnergyImage=ai;this.Elevel=vi;this.Heating=yi;this.Glazing=pi;this.Name=ko.observable(t);this.Levels=ko.observableArray()}return n}();n.FullSalesUnit=t})(t=n.Offer||(n.Offer={}))})(t=n.Components||(n.Components={}))}(Scripts||(Scripts={})),function(n){var t;(function(n){var t;(function(n){var t=function(){function n(n,t,i){this.salesUnits=[];this.totalResults=0;this.showAll=!1;this.salesUnits=t;this.totalResults=n;this.showAll=i}return n}();n.SearchResult=t})(t=n.Offer||(n.Offer={}))})(t=n.Components||(n.Components={}))}(Scripts||(Scripts={})),function(n){var t;(function(t){var i;(function(t){var i=function(){function i(n){this.projectId=n;this.apiLocation="/api/sitecore/Offer/"}return i.prototype.search=function(t,i,r,u,f){$.ajax({url:this.apiLocation+"SalesUnits?projectId="+this.projectId+"&showAllUnits="+t+"&sortOption="+i+"&descending="+r+"&isInvestPage="+u,dataType:"json",cache:!1,ifModified:!1,success:function(t){for(var u=[],i=null,r=0;r<t.SalesUnits.length;r++)i=t.SalesUnits[r],u.push(new n.Components.Offer.SalesUnit(i.Id,i.Title,i.CommercialType,i.ImageSrc,i.HasOption,i.IsCasco,i.Price,i.CascoPrice,i.DisplayPrice,i.SalesUnitBrochureLink,i.DescriptionItems,i.SalesUnitTypeLogo,i.SalesUnitHeadType,i.SalesUnitHeadTypeID,i.NumberOfBedrooms,i.IsShowHouse,i.ShowHouseID,i.Reference,i.TypeOfInterest,i.LivableArea,i.Availability,i.InvestProjectUrl));f(new n.Components.Offer.SearchResult(t.TotalResults,u,t.ShowAllUnits))}})},i.prototype.GetSalesUnit=function(t,i){$.ajax({url:this.apiLocation+"SalesUnit?salesUnitId="+t,dataType:"json",cache:!1,ifModified:!1,success:function(t){var r=new n.Components.Offer.FullSalesUnit(t.Id,t.Title,t.CommercialType,t.ImageSrc,t.HasOption,t.IsCasco,t.Price,t.CascoPrice,t.DisplayPrice,t.SalesUnitBrochureLink,t.DescriptionItems,t.SalesUnitTypeLogo,t.SalesUnitHeadType,t.SalesUnitHeadTypeID,t.NumberOfBedrooms,t.IsShowHouse,t.ShowHouseID,t.Reference,t.TypeOfInterest,t.LivableArea,t.Availability,t.InvestProjectUrl,t.NumberOfBathrooms,t.HasGarden,t.GardenDirection,t.HasTerace,t.HasGarage,t.GarageType,t.HasGarageBox,t.GarageBoxType,t.HasAttic,t.AtticType,t.HasParkingPlace,t.ParkingPlaceType,t.HasCarport,t.HasBycicleShed,t.HasShed,t.BuildableArea,t.GroundArea,t.BedRoom1Area,t.BedRoom2Area,t.BedRoom3Area,t.BedRoom4Area,t.BathRoom1Area,t.BathRoom2Area,t.BathRoom3Area,t.KitchenArea,t.LivingRoomArea,t.HallArea,t.CarportArea,t.AtticArea,t.TeraceArea,t.GardenArea,t.ShowEnergy,t.EnergyImage,t.Elevel,t.Heating,t.Glazing);i(r)}})},i.prototype.getShowhouses=function(i){$.ajax({url:this.apiLocation+"ShowHouses?projectId="+this.projectId,dataType:"json",cache:!1,ifModified:!1,success:function(r){for(var u=null,h=[],s,f,o,e=0;e<r.length;e++){for(u=r[e],s=[],f=null,o=0;o<u.Events.length;o++)f=u.Events[o],s.push(new t.ShowhouseEvent(f.ID,f.DateInformation,f.TimeInformation,f.Type,f.IsRecurring));h.push(new n.Components.Offer.ShowHouse(u.ID,u.Description,u.Address,u.Longitude,u.Latitude,u.ImageSrc,u.ImageAlt,u.URL,u.Name,u.EventLocationType,u.EventsTitle,s))}i(h)}})},i}();t.OfferSearchService=i})(i=t.Offer||(t.Offer={}))})(t=n.Components||(n.Components={}))}(Scripts||(Scripts={})),function(n){var t;(function(n){var t;(function(n){var t=function(){function t(t,i,r,u,f){this.searchService=t;this.errorSalesUnitId=r;this.onSearchLoaded=f;this.showHouses=null;this.projectId=ko.observable(i);this.allSalesUnits=[];this.filteredSalesUnits=[];this.salesUnits=ko.observableArray();this.numberOfItemsToShowPerLoad=ko.observable(u);this.numberOfItems=ko.observable(0);this.totalNumberOfItems=ko.observable(0);this.showAllUnits=ko.observable(!1);this.isFilterActive=ko.observable(!1);this.isLoading=ko.observable(!1);this.selectedSalesUnit=ko.observable(new n.SalesUnit("","","","",!1,!1,0,0,"","",[],"","",0,0,!1,"","","",0,"",""));this.selectedShowHouse=ko.observable(new n.ShowHouse("","","",0,0,"data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==","","","","","",[]));this.validSalesUnitIds=[];this.loadShowhouses()}return t.prototype.initialize=function(){this.isLoading(!0);this.searchService.search(!1,"",!0,!1,this.showInitialResults.bind(this))},t.prototype.showInitialResults=function(n){this.showResults(n,!0)},t.prototype.search=function(){this.isLoading(!0);this.searchService.search(!0,"",!0,!1,this.showResults.bind(this))},t.prototype.loadShowhouses=function(){var n=this;this.searchService.getShowhouses(function(t){n.showHouses=t}.bind(this))},t.prototype.getShowhouse=function(n){var i=null,t;return this.showHouses!=null&&(t=this.showHouses.filter(function(t){return t.ID===n.ShowHouseID}),t.length>0&&(i=t[0])),i},t.prototype.navigateToShowhouse=function(){},t.prototype.showResults=function(n,t){var r=this,i;t===void 0&&(t=!1);this.salesUnits(n.salesUnits);t&&loadAllotmentPlan();n.salesUnits.length>0&&this.errorSalesUnitId!==""&&(i=n.salesUnits.filter(function(n){return n.Id===r.errorSalesUnitId}),i.length>0&&this.selectedSalesUnit(i[0]));this.allSalesUnits=n.salesUnits;this.showSalesUnits(t);this.numberOfItems(n.salesUnits.length);this.totalNumberOfItems(n.totalResults)},t.prototype.loadMore=function(){this.isLoading(!0);setTimeout(function(){this.showAllUnits(!0);this.showSalesUnits(this.allSalesUnits.length==this.filteredSalesUnits.length)}.bind(this),100)},t.prototype.setValidSalesUnitIds=function(n){this.validSalesUnitIds=n;this.numberOfItems(this.validSalesUnitIds.length);this.showSalesUnits()},t.prototype.setOfferData=function(n){for(var t=0;t<this.allSalesUnits.length;t++)this.allSalesUnits[t].Id in n?this.allSalesUnits[t].Name(this.allSalesUnits[t].Title+"<br>"+n[this.allSalesUnits[t].Id]):this.allSalesUnits[t].Name(this.allSalesUnits[t].Title)},t.prototype.showLoadMoreButton=function(){return this.salesUnits().length<this.filteredSalesUnits.length},t.prototype.resetFilters=function(){this.resetFilter("bedrooms");this.resetFilter("buildingType");this.resetFilter("price");this.showSalesUnits()},t.prototype.resetFilter=function(n){var t=$("#"+n).selectize();t[0]!=null?t[0].selectize.setValue("-1"):$('[name="'+n+'"]').removeAttr("checked")},t.prototype.showSalesUnits=function(n){var f=this,i;n===void 0&&(n=!1);this.filteredSalesUnits=this.validSalesUnitIds.length>0?this.allSalesUnits.filter(function(n){return f.validSalesUnitIds.indexOf(n.Id)>-1&&!n.IsShowHouse}):n?this.allSalesUnits:[];var t=$("#bedrooms option:selected").val(),r=[],u=$("#buildingType option:selected").val();u==undefined?(u=1,$('[name="buildingType"]:checked').each(function(n,t){r.push($(t).val())})):r.push(u);i=$("#price option:selected").val();this.fillHubspotFilterValues(t,u,i);t!="-1"||r.length>0||i!="-1"?(this.isFilterActive(!0),this.filteredSalesUnits=this.filteredSalesUnits.filter(function(n){var o=!0,s=!0,e=!0,f;return t!=null&&t!="-1"&&(o=t==0?n.NumberOfBedrooms==0:n.NumberOfBedrooms>=t),u>0&&r.length>0&&(s=r.indexOf(n.SalesUnitHeadTypeId.toString())>=0),i!=null&&i!="-1"&&(f=i.split("-"),f.length==1?e=n.Price>=f[0]:f.length==2&&(e=n.Price>=f[0]&&n.Price<=f[1])),o&&s&&e}),this.sortSalesUnits(t!="-1",i!="-1")):this.isFilterActive(!1);this.showAllUnits()?this.salesUnits(this.filteredSalesUnits):this.salesUnits(this.filteredSalesUnits.slice(0,this.numberOfItemsToShowPerLoad()));this.numberOfItems(this.filteredSalesUnits.length);this.totalNumberOfItems(this.allSalesUnits.length);this.onSearchLoaded(n);this.isLoading(!1)},t.prototype.sortSalesUnits=function(n,t){n?this.filteredSalesUnits.sort(function(n,t){return n.NumberOfBedrooms===t.NumberOfBedrooms?n.Price<t.Price?-1:n.Price>t.Price?1:0:n.NumberOfBedrooms<t.NumberOfBedrooms?-1:1}):t?this.filteredSalesUnits.sort(function(n,t){return n.Price<t.Price?-1:n.Price>t.Price?1:0}):this.filteredSalesUnits.sort(function(n,t){return n.Name<t.Name?-1:n.Name<t.Name?1:0});return},t.prototype.selectSalesUnit=function(n){this.selectedSalesUnit(n);n.IsShowHouse&&this.selectedShowHouse(this.getShowhouse(n));this.fillHubspotSuValues()},t.prototype.fillHubspotSuValues=function(){var n=$("#SU_Form"),t;n&&n.length!=0&&(n.find('input[name="su_number"]').length>0&&n.find('input[name="su_number"]').val(this.selectedSalesUnit().Reference).change(),n.find('input[name="su_name"]').length>0&&n.find('input[name="su_name"]').val(this.selectedSalesUnit().Title).change(),n.find('input[name="su_type_of_interest"]').length>0&&n.find('input[name="su_type_of_interest"]').val(this.selectedSalesUnit().TypeOfInterest).change(),n.find('input[name="su_list_price"]').length>0&&(t=this.selectedSalesUnit().DisplayPrice.replace("€","").trim(),n.find('input[name="su_list_price"]').val(t).change()))},t.prototype.fillHubspotFilterValues=function(n,t,i){var r=$("#SU_Form"),e,f,u;r&&r.length!=0&&(e="",n!="-1"&&(e=$("#bedrooms option:selected").text()),r.find('input[name="selected_bedrooms"]').length>0&&r.find('input[name="slected_bedrooms"]').val(e).change(),r.find('input[name="filter_bedrooms"]').length>0&&r.find('input[name="filter_bedrooms"]').val(e).change(),f="",t!="-1"&&(f=$("#buildingType option:selected").text()),r.find('input[name="selected_type"]').length>0&&r.find('input[name="selected_type"]').val(f).change(),r.find('input[name="filter_type"]').length>0&&r.find('input[name="filter_type"]').val(f).change(),u="",i!="-1"&&(u=$("#price option:selected").text(),u=u.replace("€","").trim()),r.find('input[name="selected_price"]').length>0&&r.find('input[name="selected_price"]').val(u).change(),r.find('input[name="filter_price"]').length>0&&r.find('input[name="filter_price"]').val(u).change())},t}();n.OfferSearchViewModel=t})(t=n.Offer||(n.Offer={}))})(t=n.Components||(n.Components={}))}(Scripts||(Scripts={}));offerSearchViewModel=null;offerSearchViewModel=null;$(document).ready(function(){var n=$(".js-allotment")[0],t=n.getAttribute("data-guid"),i=$("#errorSalesUnitID").val();offerSearchViewModel=new Scripts.Components.Offer.OfferSearchViewModel(new Scripts.Components.Offer.OfferSearchService(t),t,i,10,function(n){if(setTimeout(function(){$(".js-salesunit-modal").magnificPopup({type:"inline",midClick:!0,mainClass:"mfp-fade"})}),n){var t=$("#offer").data("error-sales-unit-guid");t.length>0&&selectSalesUnit(t)}});ko.applyBindings(offerSearchViewModel,n);offerSearchViewModel.initialize();getOfferSearchViewModel(offerSearchViewModel)})