1"use strict";function validateFinanceDeposit(){var e=$("#quotefilters-deposit");if(!e.length)return!0;var t=e.closest(".form-group"),a=t.find(".help-block-error");a.length||(a=$('<div class="help-block help-block-error"></div>'),t.append(a));var i=$.trim(e.val()).replace(/[£,\s]/g,""),n="";return/^\d+(\.\d+)?%?$/.test(i)?/%$/.test(i)&&parseFloat(i)>100&&(n="Percentage cannot be greater than 100%."):n="Please enter a number (e.g. £2000) or a percentage (e.g. 20%).",n?(a.text(n).show(),t.addClass("has-error"),e.focus(),!1):(a.hide().text(""),t.removeClass("has-error"),!0)}function renderRepresentative(e){const t={};"object"==typeof e.Quote.Fees&&e.Quote.Fees.forEach(function(e){t[e.FeeType]=e.Amount});var a=cleanFinanceKey(e.Key);representativeExample.update({price:e.Quote.TotalPrice,product:a,deposit:e.Quote.Deposit,term:e.Quote.Term,monthlyPayment:e.Quote.AllInclusiveRegularPayment.toFixed(2),finalPayment:e.Quote.FinalPayment.toFixed(2),creditAmount:e.Quote.AmountOfCredit,totalPayable:e.Quote.TotalAmountPayable,totalCharges:e.Quote.TotalChargeForCredit,annualMileage:e.Quote.AnnualMileage,apr:e.Quote.Apr,interestRate:e.Quote.RateOfInterest,optionToPurchaseFee:t.Option||0,excessMileageFee:e.Quote.ExcessMileageRate})}function cleanFinanceKey(e){return"LEASE_PURCHASE"===e?e="LP":"BH_PCP"===e||"ALPHERA_PCP"===e||"DSG PCP"===e||"BLACK HORSE PCP"===e?e="PCP":"BH_HP"!==e&&"DSG HP"!==e&&"BLACK HORSE HP"!==e||(e="HP"),0===e.indexOf("CS_")&&(e="CS"),0===e.indexOf("HP_")&&(e="HP"),0===e.indexOf("PCP_")&&(e="PCP"),0===e.indexOf("LP_")&&(e="LP"),e}if(console.log=function(){},window.priceCodeweavers=function(e){var t=["PCP","HP","LP"],a=["CS"],i=defaultCodeweaversRequest;if(e){var n=$("#quotefilters-term").val(),r=$("#quotefilters-deposit").val().replace(/[£,]/g,""),s=$("#quotefilters-annualmileage").val();i.Parameters.Term=n,i.Parameters.Deposit=r,i.Parameters.AnnualMileage=s}-1!==i.Parameters.Deposit.indexOf("%")?(i.Parameters.DepositType="Percentage",i.Parameters.Deposit=i.Parameters.Deposit.replace("%",""),parseFloat(i.Parameters.Deposit)>100&&(i.Parameters.Deposit=100)):i.Parameters.DepositType="Amount",i.Parameters.Deposit<0&&(i.Parameters.Deposit=0),window.priceCodeweaversApiParameters=i.Parameters,$(".js-vehicle-full").length||(localStorage.setItem("pluginDeposit",i.Parameters.Deposit),localStorage.setItem("pluginDepositType",i.Parameters.DepositType)),localStorage.getItem("pluginDeposit")&&localStorage.getItem("pluginDepositType")&&i.hasOwnProperty("Custom")&&!i.Custom&&(i.Parameters.Deposit=localStorage.getItem("pluginDeposit"),i.Parameters.DepositType=localStorage.getItem("pluginDepositType"));var l,c=!1,o=$(".js-finance-template").html(),p=0;representativeExample.isConfiguredPlugin()&&((l=$('<ul id="'+representativeExample.id+'"></ul>')).addClass("finance-summary"),l.data("vehicle-useextendedinformations",1).data("vehicle-id",representativeExample.id).data("vehicle-identifier",representativeExampleVehicle.capCode?representativeExampleVehicle.capCode:representativeExampleVehicle.vrm).data("vehicle-identifiertype",representativeExampleVehicle.capCode?"CapShortCode":"Vrm").data("vehicle-isnew",!1).data("vehicle-cashprice",representativeExampleVehicle.vehiclePrice).data("vehicle-mileage",representativeExampleVehicle.mileage).data("vehicle-registrationnumber",representativeExampleVehicle.vrm).data("vehicle-registrationdate",representativeExampleVehicle.registrationDate).data("vehicle-type",representativeExampleVehicle.vehicleTypeName),$("body").append(l[0])),$(".finance-summary").each(function(e){p++;var n=$(this),r=n.attr("id"),s=n.data("vehicleId");if(i.VehicleRequests[0].Vehicle={},"1"==n.data("vehicle-useextendedinformations")){"Car"!=n.data("vehicle-type")&&"Bike"!=n.data("vehicle-type")&&(i.VehicleRequests[0].Vehicle.ImageUrl=n.data("vehicle-imageurl")?n.data("vehicle-imageurl"):"",i.VehicleRequests[0].Vehicle.DealerVehicleUrl=n.data("vehicle-linkbackurl")?n.data("vehicle-linkbackurl"):"","false"!=n.data("vehicle-isvatqualifying")&&"true"!=n.data("vehicle-isvatqualifying")||(i.VehicleRequests[0].Vehicle.IsVatQualifying=n.data("vehicle-isvatqualifying")));var l=n.data("vehicle-isnew")&&parseInt(n.data("vehicle-mrrp"))>0?n.data("vehicle-mrrp"):n.data("vehicle-cashprice");i.VehicleRequests[0].Dealer=n.data("vehicle-dealerkey"),i.VehicleRequests[0].Vehicle.CashPrice=l,i.VehicleRequests[0].Vehicle.CurrentMileage=n.data("vehicle-mileage"),i.VehicleRequests[0].Vehicle.RegistrationDate=n.data("vehicle-registrationdate")?n.data("vehicle-registrationdate"):"",i.VehicleRequests[0].Vehicle.IsNew=n.data("vehicle-isnew"),i.VehicleRequests[0].Vehicle.Identifier=n.data("vehicle-identifier")?n.data("vehicle-identifier"):"",i.VehicleRequests[0].Vehicle.IdentifierType=n.data("vehicle-identifiertype")?n.data("vehicle-identifiertype"):"",i.VehicleRequests[0].Vehicle.Type=n.data("vehicle-type")?n.data("vehicle-type"):"",i.VehicleRequests[0].Vehicle.StockId=s||"",i.VehicleRequests[0].Vehicle.VIN=n.data("vehicle-vin")?n.data("vehicle-vin"):""}else{var u="";switch($(".js-vehicle").data("vehicle-type")){case"car":u="Car";break;case"bike":u="Bike";break;default:u="LCV"}i.VehicleRequests[0].Vehicle.stockId=s,i.VehicleRequests[0].Vehicle.type=u}!function(e,n,r){var s=!0;$.ajax({url:"https://services.codeweavers.net/public/v3/JsonFinance/Calculate",type:"POST",contentType:"application/json",data:JSON.stringify(i),success:function(l){if(!c&&l.hasOwnProperty("RepresentativeExample")&&!l.RepresentativeExample.HasError&&l.RepresentativeExample.hasOwnProperty("Quote")&&(representativeExample.isConfiguredPlugin()&&n===representativeExample.id||!representativeExample.isConfiguredPlugin())&&(c=!0,renderRepresentative(l.RepresentativeExample)),l.hasOwnProperty("VehicleResults")&&l.VehicleResults.length>0&&l.VehicleResults[0].FinanceProductResults.length>0){var p=[],u=null,d=l.VehicleResults[0].FinanceProductResults;if(d.length){d[0].Quote?u=d[0].Quote.QuoteReference:d.length>1&&d[1].Quote&&(u=d[1].Quote.QuoteReference);
1const t=e.closest(".js-vehicle");if(t.length){const e=t.find(".js-codeweavers-finance-check-custom").first();e.length&&void 0!==u&&e.attr("data-quote-reference",u)}l.VehicleResults[0].FinanceProductResults.forEach(function(e){var t=cleanFinanceKey(e.Key);if(!1===e.HasError){const a={};e.Quote.Fees.forEach(function(e){a[e.FeeType]=e.Amount}),financeTypes.isAllowedToProcess(t)&&p.push({hasErrors:e.HasError,FacilityType:t,FirstPayment:e.Quote.Payments[0].Amount,RegularPayment:e.Quote.RegularPayment,FinalPayment:e.Quote.FinalPayment,Term:e.Quote.Term,DepositContribution:e.Quote.DepositContribution,CashDeposit:e.Quote.CashDeposit,TotalDeposit:e.Quote.TotalDeposit,BalanceToFinance:e.Quote.Balance,TotalPayable:e.Quote.TotalAmountPayable,InterestRate:e.Quote.RateOfInterest,TotalCashPrice:e.Quote.CashPrice,APR:e.Quote.Apr,AcceptanceFee:a.Admin||0,OptionToPurchaseFee:a.Option||0,ApplyURL:e.Quote.QuoteActions.Apply,ExcessMileageRate:e.Quote.ExcessMileageRate||0,ExcessMileageRateVisibility:"HP"===t?"hide ":""})}else p.push({hasErrors:e.HasError})})}if($(".js-vehicle-full").length){if(1==r&&o){m=_.template(o)({Quotes:p});var h=$.parseHTML(m);$(".js-deposit-contribution .finance-item__value",h).each(function(e){if("£0.00"===$(this).text()){var t=$(this).closest(".finance-table__container");$(".js-deposit-contribution, .js-cash-deposit",t).hide()}}),$(".listing__finance-quotes").html(h),$(".listing__finance-quotes #admin-fee").each(function(e){0===$(this).data("value")?$(this).parent().hide():$(this).parent().show()})}}else{e.parents(".js-vehicle-teaser").find(".finance-table--teaser").length>0&&e.parents(".js-vehicle-teaser").find(".finance-table--teaser").remove();var m=_.template(o)({Quotes:p});e.parents(".js-vehicle-teaser").find(".js-finance-wrapper").prepend(m)}}if(l.hasOwnProperty("HasError")&&l.HasError||l.hasOwnProperty("RepresentativeExample")&&!l.RepresentativeExample.hasOwnProperty("Quote"))return e.parents(".js-vehicle-teaser, .js-vehicle-embedded-teaser").find(".js-finance-price").hide(),e.parents(".js-vehicle-teaser, .js-vehicle-embedded-teaser").find(".js-finance-summary").hide(),1==r&&0===e.closest(".js-vehicle-embedded-teaser").length&&$(".js-vehicle-full").length&&$(".finance-price--full.js-finance-price").hide(),!1;var f=[],v=[],g=[],P={HP:"https://player.vimeo.com/video/106279545",PCP:"https://player.vimeo.com/video/105355895",LP:"https://player.vimeo.com/video/165438014",CS:"https://player.vimeo.com/video/189119465"};if(l.VehicleResults.length&&l.VehicleResults[0].FinanceProductResults.length){var y={PCP:null,HP:null,LP:null,CS:null};l.VehicleResults[0].FinanceProductResults.forEach(function(e){if(!e.HasError){f.push(e.Quote.AllInclusiveRegularPayment),e.Quote.Deposit&&v.push(e.Quote.Deposit);var a=cleanFinanceKey(e.Key);y[a]&&y[a].price<e.Quote.AllInclusiveRegularPayment||(s&&-1!==$.inArray(a,t)&&(s=!1),y[a]={finance:{key:a,value:e.Quote.AllInclusiveRegularPayment,video:P.hasOwnProperty(a)?P[a]:""},price:e.Quote.AllInclusiveRegularPayment})}});var x=financeTypes.isConfiguredPlugin()?prioritiseFinanceTypes:s?a:t;if($.each(x,function(e,t){if(y[t]&&(g.push(y[t].finance),s))return!1}),!g.length)return e.parents(".js-vehicle-teaser").find(".js-finance-price").hide(),$(".js-vehicle-full").length&&$(".js-finance-price").hide(),!1;var R={};g.forEach(function(e){(void 0===$(R).attr(e.key)||$(R).attr(e.key).value>e.value)&&$(R).attr(e.key,e)}),e.parents(".js-vehicle-teaser, .js-vehicle-embedded-teaser").find(".js-finance-price-list").html("");var C="",E=void 0,j="";$.each(R,function(e,t){var i=!1;if(financeTypes.isConfiguredPlugin()){var n=prioritiseFinanceTypes.indexOf(t.key);-1!=n&&(void 0===E||n<E)&&(E=n,C="",i=!0)}else-1!==$.inArray(t.key,a)?j.length||(j=financeRenderHtml.priceList(t.key,financeHelper.formatNumber(t.value.toFixed(2)))):i=!0;i&&(C+=financeRenderHtml.priceList(t.key,financeHelper.formatNumber(t.value.toFixed(2))))});var b=C.length?C:j;e.parents(".js-vehicle-teaser, .js-vehicle-embedded-teaser").find(".js-finance-price-list").html(b),1==r&&$(".js-vehicle-full").length?($(".js-finance-price-list").first().html(b),"Percentage"===i.Parameters.DepositType?$(".js-finance-price-deposit").html("£"+financeHelper.formatNumber(Math.min.apply(null,v).toFixed(2))):$(".js-finance-price-deposit").html("£"+financeHelper.formatNumber(parseFloat(i.Parameters.Deposit).toFixed(2)))):(e.html(""),$.each(R,function(t,a){e.append("<li><div class='finance-summary-type finance-summary-type--"+a.key.toLowerCase()+"'><div class='finance-summary-type__key'>"+a.key+"</div><div class='finance-summary-type__value'><span>£"+financeHelper.formatNumber(a.value.toFixed(2))+"</span> per month</div><a href='"+a.video+"' class='finance-summary-type__video' data-fancybox>What is "+a.key+"?</a></div></li>")}))}}})}(n,r,p)})},$("#js-vehicle-list-wrapper, .js-vehicle-full").on("click",".js-codeweavers-finance-check-custom",function(e){e.preventDefault();const t=$(this),a=t.data("quote-reference"),i=t.data("api-key");if(!a||!i)return;const n="https://services.codeweavers.net/navigator/redirectToApplication/motor-credit-check?"+new URLSearchParams({apiKey:i,quoteReference:a}).toString();window.open(n,"_blank","noopener, noreferrer")}),$("#js-finance-form-button").click(function(e){e.preventDefault(),validateFinanceDeposit()&&priceCodeweavers(!0)}),$(".listing__finance-quotes").on("click",".js-build-my-deal",function(e){e.preventDefault(),window.priceCodeweaversApiParameters&&$.ajax({type:"POST",dataType:"json",url:"/vehicle/my-deal",data:{term:window.priceCodeweaversApiParameters.Term,deposit:window.priceCodeweaversApiParameters.Deposit,mileage:window.priceCodeweaversApiParameters.AnnualMileage}
1,complete:function(){var e=$('a.js-vehicle-payment-btn[data-in-progress-text="Purchase in Progress"]');e.length?e[0].click():(e=$('a.js-vehicle-payment-btn:contains("Buy")')).length?e[0].click():(e=$('a.js-vehicle-payment-btn:contains("Purchase")')).length?e[0].click():$(".js-vehicle-payment-btn")[0].click()}})}),void 0===financeHelper)var financeHelper={deposit:function(e){var t=localStorage.getItem("pluginDeposit"),a=localStorage.getItem("pluginDepositType");if((localStorage.getItem("financePluginDeposit")||void 0!==$("#quotefilters-deposit").val())&&(null===(t=localStorage.getItem("financePluginDeposit"))&&(t=$("#quotefilters-deposit").val().replace(/[£,]/g,"")),"%"===t.slice(-1)&&(t=t.substr(0,t.length-1),a="Percentage")),t&&a&&"Percentage"===a){if(t>99)return 0;t*=e/100}return t||0},mileage:function(){var e=localStorage.getItem("financePluginMileage");return e||void 0===$("#quotefilters-annualmileage").val()||(e=$("#quotefilters-annualmileage").val()),e},formatNumber:function(e,t){var a=e;return null===a?a:(void 0===t&&(t=2),a="string"==typeof a?parseFloat(a).toFixed(t):a.toFixed(t),isNaN(a)&&(a=e),a.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,"))}};if(void 0===financeRenderHtml)var financeRenderHtml={priceList:function(e,t){var a=this.extractProductName(e);a.length&&(a="("+a+")"),"POA"!==t&&(t="£"+t);var i='<li class="finance-price__list-item js-finance-price-list-item">';return i+='<span class="finance-price__value js-finance-price-value">'+t+"</span>",i+='<span class="finance-price__label js-finance-price-label">'+a+"</span>",i+="</li>"},extractProductName:function(e){var t="";return e.length&&(t=e,e.includes("_")&&(t=e.substring(0,e.indexOf("_")))),t}};if(void 0===financeTypes)var financeTypes={isConfiguredPlugin:function(){return!("undefined"==typeof prioritiseFinanceTypes||1===prioritiseFinanceTypes.length&&""===prioritiseFinanceTypes[0])},isAllowedToProcess:function(e){return!this.isConfiguredPlugin()||-1!==prioritiseFinanceTypes.indexOf(e)}};var representativeExampleParams={price:null,product:null,deposit:null,term:null,monthlyPayment:null,finalPayment:null,creditAmount:null,totalPayable:null,totalCharges:null,annualMileage:null,apr:null,interestRate:null,optionToPurchaseFee:null,excessMileageFee:null};if(void 0===representativeExample)var representativeExample={id:"finance-representative-example",selector:"#js-finance-example",paramsSelectorPrefix:".js-finance-example-",params:representativeExampleParams,initialize:function(){return _.forEach(representativeExample.params,function(e,t){switch(t){case"price":case"deposit":case"monthlyPayment":case"finalPayment":case"creditAmount":case"totalPayable":case"totalCharges":case"interestRate":case"optionToPurchaseFee":e=financeHelper.formatNumber(e,2);break;case"apr":e=financeHelper.formatNumber(e,1);break;case"annualMileage":case"excessMileageFee":e=financeHelper.formatNumber(e,0)}$(representativeExample.paramsSelectorPrefix+t).html(e)}),this.display(),!0},update:function(e){return this.resetParams(),_.forEach(e,function(e,t){void 0!==representativeExample.params[t]&&(representativeExample.params[t]=e)}),this.initialize()},resetParams:function(){this.params=representativeExampleParams}
1,display:function(){var e=$(this.selector).find("#js-finance-disclaimer");e.length&&("PCP"===this.params.product?e.removeClass("hide"):e.hasClass("hide")||e.addClass("hide")),"HP"===this.params.product&&this.hideMileage(),document.querySelectorAll(this.selector).forEach(e=>{$(e).removeClass("hide")})},hideMileage:function(){$(this.selector).find(".js-finance-example-annual-mileage, .js-finance-example-excess-mileage").hide()},isConfiguredPlugin:function(){return"undefined"!=typeof representativeExampleVehicle}};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.