"use strict";(function(n,t,i,r,u){n.MultipleDealerMapView=r.View.extend({el:".multiple-dealer-map",events:{"submit .multiple-dealer-map__search":"geocodeAddress"},initialize:function(){var t=i.bind(this.render,this);n.scripts.getGoogleMaps().then(t)},render:function(){var f,e,r;this.center=new google.maps.LatLng(40.9006,174.886);this.map=new google.maps.Map(this.$(".block-map__holder").get(0),{zoom:6,minZoom:4,center:this.center,scrollwheel:!1,mapTypeControl:!1,streetViewControl:!1,fullscreenControl:!1,styles:n.helpers.googleMapStyles()});this.geocoder=new google.maps.Geocoder;f=i.bind(this.updateCenter,this);this.map.addListener("center_changed",i.debounce(f,300));e=i.bind(this.resizeMap,this);this.map.addListener("resize",e);r=i.bind(function(){google.maps.event.trigger(this.map,"resize")},this);t(u).on("resize",i.debounce(r,300));t(u).on("breakpoint.change",r);return this.getDealers(),this.infoWindow=new google.maps.InfoWindow,this.dealerProfileModal||(this.dealerProfileModal=new n.DealerProfileModalView),this},initializeMapZoom:function(){var t=i.bind(function(n,t){this.map.setZoom(n);this.map.setCenter(new google.maps.LatLng(t.latitude,t.longitude));this.updateCenter()},this),r=i.bind(function(r){var u=r.coords,f={location:{lat:u.latitude,lng:u.longitude}};this.geocoder.geocode(f,i.bind(function(i,r){var f,e;r==="OK"&&(f=n.helpers.getCountryFromGeoResult(i),f&&f.toUpperCase()==="NZ"&&(e=parseFloat(this.$el.attr("data-zoom")),t(e,u)))},this))},this);"geolocation"in navigator&&navigator.geolocation.getCurrentPosition(r)},updateCenter:function(){this.center=this.map.getCenter()},resizeMap:function(){this.map.panTo(this.center)},positionMap:function(){var n=new google.maps.LatLngBounds;this.markers.map(function(t){n.extend(t.getPosition())});this.center=n.getCenter();this.map.fitBounds(n);this.map.setCenter(this.center);this.initializeMapZoom()},getDealers:function(){var t=i.bind(this.addMarkers,this);n.dealerService.getAll().then(t)},addMarkers:function(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];this.markers=t.map(function(t){return this.createMarker(t,n.currentDealerId&&n.currentDealerId==t.id)},this);this.positionMap();this.createMarkerCluster()},createMarker:function(n,t){var e=t?"dealer-current":n.branchType===0?"dealer":"service",u=t?60:40,f=t?75:50,r=new google.maps.Marker({position:new google.maps.LatLng(n.latitude,n.longitude),icon:{url:"/Content/niban/images/marker-"+e+".svg",size:new google.maps.Size(u,f),origin:new google.maps.Point(0,0),anchor:new google.maps.Point(u/2,f),scaledSize:new google.maps.Size(u,f)},optimized:!1});return r.addListener("click",i.bind(function(){this.showDealerProfileModal(n)},this)),r.addListener("mouseover",i.bind(function(){this.infoWindow.setContent(n.displayName);this.infoWindow.open(this.map,r)},this)),r.addListener("mouseout",i.bind(function(){this.infoWindow.close()},this)),r},createMarkerCluster:function(){this.markerCluster=new MarkerClusterer(this.map,this.markers,{maxZoom:18,styles:[{fontFamily:'"Helvetica Neue", Helvetica, Arial, sans-serif',textColor:"#ffffff",textSize:18,height:40,width:40,url:"/Content/niban/images/marker-cluster.svg"}]})},geocodeAddress:function(n){var t=this.$(".multiple-dealer-map__search-input > input").val(),r={address:t,componentRestrictions:{country:"NZ"}};n.preventDefault();this.geocoder.geocode(r,i.bind(function(n,t){t==="OK"&&(this.map.setCenter(n[0].geometry.location),this.map.fitBounds(n[0].geometry.bounds))},this))},showDealerProfileModal:function(n){this.renderDealerProfileOverlay(n)},renderDealerProfileOverlay:function(n){this.dealerProfileModal.hide();this.dealerProfileModal.updateModel(n);this.dealerProfileModal.show()}})})(window.tnz=window.tnz||{},jQuery,_,Backbone,window),function(n,t,i,r){n.DealerBranchListingView=r.View.extend({events:{"click .dealer-list > ul > li > a":"getDealer"},showDealerProfileModal:function(t){!this.dealerProfileModal&&n.multipleDealerMap.dealerProfileModal&&(this.dealerProfileModal=n.multipleDealerMap.dealerProfileModal);this.dealerProfileModal||(this.dealerProfileModal=new n.DealerProfileModalView);this.renderDealerProfileOverlay(t)},getDealer:function(r){var u=t(r.currentTarget).data("dealer"),f=i.bind(this.showDealerProfileModal,this);r.preventDefault();n.dealerService.get(u).then(f)},renderDealerProfileOverlay:function(n){this.dealerProfileModal.hide();this.dealerProfileModal.updateModel(n);this.dealerProfileModal.show()}})}(window.tnz=window.tnz||{},jQuery,_,Backbone,window),function(n,t,i,r,u){n.CarouselView=r.View.extend({initialize:function(){this.render()},render:function(){function r(){var t=n.find(".block-carousel__media"),u=n.find(".block-carousel__slide"),i=t.outerWidth(),r=u.outerWidth(),f=i>r?(i-r)/-2:0;t.css("margin-left",f)}var n=this.$el,f=this.$(".block-carousel__slider");f.slick({dots:!0,arrows:!0,cssEase:"cubic-bezier(0.5, 0, 0.5, 1)",prevArrow:'<button type="button" class="slick-prev"><\/button>',nextArrow:'<button type="button" class="slick-next"><\/button>',appendArrows:n,appendDots:n,touchThreshold:10,focusOnSelect:!1,adaptiveHeight:!0,useTransform:!0,accessibility:!1});r();t(u).on("load resize orientationchange",i.debounce(r,300));return this}})}(window.tnz=window.tnz||{},jQuery,_,Backbone,window),function(n,t,i,r,u,f){n.CarouselAboveTheFoldView=r.View.extend({initialize:function(){this.render()},render:function(){function o(){var i=t(f).height(),o=t("#header").height(),s=r.find(".block-call-to-action").outerHeight(),c=r.find(".block-carousel__wrapper").outerHeight(),h=i-o-s;n.breakpoint.is("sm")?(e.height(h),u(this.$(".block-carousel__slide img"))):(r.css("height",""),e.css("height",""))}var r=this.$el,e=r.find(".block-carousel__slider");t(f).on("load",function(){e.find(".slick-track").velocity("fadeIn")});t(f).on("load resize orientationchange",i.debounce(o,300));return this}})}(window.tnz=window.tnz||{},jQuery,_,Backbone,objectFitImages,window),function(n,t,i,r){n.ContactSliderView=r.View.extend({initialize:function(){this.render()},render:function(){var n=this.$(".block-contact__slider");return n.slick({accessibility:!1,swipeToSlide:!0,cssEase:"cubic-bezier(0.5, 0, 0.5, 1)",focusOnSelect:!1,slidesToShow:1,prevArrow:'<button type="button" class="slick-prev"><\/button>',nextArrow:'<button type="button" class="slick-next"><\/button>',useTransform:!0,infinite:!1,mobileFirst:!0,variableWidth:!0,appendArrows:n.closest(".block-contact"),appendDots:n.closest(".container"),responsive:[{breakpoint:480,settings:{slidesToShow:2,variableWidth:!1}},{breakpoint:992,settings:{slidesToShow:3,variableWidth:!1}},{breakpoint:1200,settings:{slidesToShow:4,variableWidth:!1}}]}),this}})}(window.tnz=window.tnz||{},jQuery,_,Backbone,window),function(n,t,i,r){n.GallerySliderView=r.View.extend({initialize:function(){this.render()},render:function(){var n=this.$(".block-gallery__slider");if(n.children().length!==1)return n.slick({dots:!0,accessibility:!1,slidesToShow:1,swipeToSlide:!0,infinite:!0,cssEase:"cubic-bezier(0.5, 0, 0.5, 1)",focusOnSelect:!1,prevArrow:'<button type="button" class="slick-prev"><\/button>',nextArrow:'<button type="button" class="slick-next"><\/button>',useTransform:!0,touchThreshold:10,mobileFirst:!0,variableWidth:!1,appendArrows:n.closest(".block-gallery"),appendDots:n.closest(".container"),centerMode:!0,centerPadding:0}),this}})}(window.tnz=window.tnz||{},jQuery,_,Backbone,window),function(n,t,i,r){n.BlogPreviewSliderView=r.View.extend({initialize:function(){this.render()},render:function(){var n=this.$(".blog-preview__slider");if(!(n.children().length<=3))return n.slick({dots:!0,accessibility:!1,swipeToSlide:!0,infinite:!1,cssEase:"cubic-bezier(0.5, 0, 0.5, 1)",focusOnSelect:!1,prevArrow:'<button type="button" class="slick-prev"><\/button>',nextArrow:'<button type="button" class="slick-next"><\/button>',useTransform:!0,touchThreshold:10,mobileFirst:!0,appendArrows:n.closest(".block-preview-gallery"),appendDots:n.closest(".block-container"),centerMode:!1,centerPadding:0,responsive:[{breakpoint:768,settings:{slidesToShow:3,variableWidth:!1}},{breakpoint:480,settings:{slidesToShow:1,variableWidth:!1}}]}),this}})}(window.tnz=window.tnz||{},jQuery,_,Backbone,window),function(n,t,i,r,u){n.CallToActionView=r.View.extend({initialize:function(){this.render()},render:function(){this.applyEqualHeights();t(u).on("breakpoint.change",i.bind(this.applyEqualHeights,this));return this},applyEqualHeights:function(){var i=this.$("ul > li > a").height(""),n=0;i.each(function(){var i=t(this).height();i>n&&(n=i)}).height(n)}});t(".block-call-to-action").each(function(){new n.CallToActionView({el:this})})}(window.tnz=window.tnz||{},jQuery,_,Backbone,window)