!function(e){var r={};function t(a){if(r[a])return r[a].exports;var n=r[a]={i:a,l:!1,exports:{}};return e[a].call(n.exports,n,n.exports,t),n.l=!0,n.exports}t.m=e,t.c=r,t.d=function(e,r,a){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:a})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var a=Object.create(null);if(t.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)t.d(a,n,function(r){return e[r]}.bind(null,n));return a},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=340)}({340:function(e,r){$((function(){$(document).on("click",".place-order",(function(e){if("AFFIRM_PAYMENT"!==$(".payment-information").data("payment-method-id"))return!0;if(!$("#vcn-data").data("affirmselected")||window.vcn_approved)return!0;var r=$("#vcn-data").data("vcndata");if($("#affirm-inline-container").length>0&&affirm.checkout.init(),$("#vcn-data").data("enabled")){var t=$(this);$("#vcn-data").data("vcncomplete","true"),e.preventDefault(),affirm.checkout.open_vcn({success:function(e){$.ajax({url:$("#vcn-data").data("updateurl")+"?"+$("#vcn-data").data("csrfname")+"="+$("#vcn-data").data("csrftoken"),data:e,dataType:"json",method:"POST",success:function(e){e.error?$("div.error-form").length?$("div.error-form").text($("#vcn-data").data("errormessages").default):$("table.item-list").before("<div class='error-form'>"+$("#vcn-data").data("errormessages").default+"</div>"):(window.vcn_approved=!0,t.click())},error:function(e){$("table.item-list").before('<div class="error-form">Error in establishing connection with Affirm VCN service!</div>')},done:function(){}})},error:function(e){if("canceled"!=e.reason&&"closed"!=e.reason){var r,t=$("#vcn-data").data("errormessages");r=t[e.reason]||t.default,$("div.error-form").length?$("div.error-form").text(r):$("table.item-list").before("<div class='error-form'>"+r+"</div>")}else window.location.assign($("#vcn-data").data("errorurl"))},checkout_data:r})}else"modal"==r.metadata.mode?(e.preventDefault(),affirm.checkout(r),affirm.checkout.open({onFail:function(e){window.location.assign(r.merchant.user_cancel_url)},onSuccess:function(e){var t=$("#vcn-data").data("csrfname")+"="+$("#vcn-data").data("csrftoken"),a=r.merchant.user_confirmation_url+"?checkout_token="+e.checkout_token+"&"+t;window.location.assign(a)}})):(e.preventDefault(),affirm.checkout(r),affirm.checkout.post())})),$(document).on("product:afterAttributeSelect",(function(e,r){var t=null,a=r.data.product,n=r.data.driveCustomizerPrice;n&&n.sales?t=n.sales.value:n&&n.list?t=n.list.value:n&&n.startingFromPrice?t=n.startingFromPrice.sales.value:a.price.sales?t=a.price.sales.value:a.price.list?t=a.price.list.value:a.price.startingFromPrice&&(t=a.price.startingFromPrice.sales.value),$(".affirm-as-low-as").attr("data-amount",(100*t).toFixed()),void 0!==affirm.ui.refresh&&affirm.ui.refresh()})),$(document).on("checkout:updateCheckoutView",(function(e,r){$(".affirm-product-modal").attr("data-amount",(100*r.order.totals.grandTotal.substr(1)).toFixed()),void 0!==affirm.ui.refresh&&affirm.ui.refresh()})),affirm.ui.ready((function(){affirm.ui.error.on("close",(function(){window.location.replace($("#vcn-data").data("errorurl"))}))}))}))}});
//# sourceMappingURL=vcn.js.map