{"version":3,"file":"default/js/v12FinanceProducts.js","mappings":";;;;;;;;;AAAA;AACA,IAAI,KAAyC;AAC7C,IAAI,iCAAO,EAAE,mCAAE;AACf;AACA,KAAK;AAAA,kGAAC,GAAG,CAGsD;AAC/D,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8CAA8C,yBAAyB;AACvE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wFAAwF;AACxF;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB;AACjB;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B,qBAAqB;AAChD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iCAAiC;AACjC;AACA,8BAA8B;AAC9B;AACA;AACA;AACA,0BAA0B;AAC1B;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyB;AACzB;AACA;AACA;AACA;AACA,6BAA6B,gEAAgE;AAC7F;AACA;AACA;AACA,CAAC;;;;;;UCzGD;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;;;;;;;ACtBA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,kBAAkB,+BAA+B;AACjD;AACA;AACA;AACA;AACA,EAAE;AACF;AACA,iBAAiB,qBAAqB;AACtC;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,2CAA2C;AAC3C;AACA;AACA;AACA,wDAAwD;AACxD;AACA;AACA,oDAAoD;AACpD,qEAAqE;AACrE,2CAA2C;AAC3C;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,oCAAoC,EAAE;AACtC,sDAAsD,GAAG;AACzD,IAAI;AACJ,6DAA6D,IAAI;AACjE;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,GAAG;AACH;AACA;;AAEA;AACA;AACA;AACA,GAAG;AACH;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,qBAAqB;AACtC;AACA;AACA;AACA,sDAAsD;AACtD,sEAAsE;AACtE,4CAA4C;AAC5C;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,EAAE;;AAEF;AACA;AACA,EAAE;;AAEF;AACA;AACA,EAAE;;AAEF;AACA;AACA;AACA;AACA;AACA,EAAE;AACF,CAAC;;;;;;;;ACvLD,mBAAO,CAAC,yEAAe,IAAI","sources":["webpack://sfra-startup-kit/./node_modules/svg4everybody/dist/svg4everybody.js","webpack://sfra-startup-kit/webpack/bootstrap","webpack://sfra-startup-kit/./cartridges/link_osfv12/cartridge/client/default/js/v12FinanceProducts.js","webpack://sfra-startup-kit/./node_modules/svg-spritemap-webpack-plugin/svg4everybody-helper.js"],"sourcesContent":["!function(root, factory) {\n \"function\" == typeof define && define.amd ? // AMD. Register as an anonymous module unless amdModuleId is set\n define([], function() {\n return root.svg4everybody = factory();\n }) : \"object\" == typeof module && module.exports ? // Node. Does not work with strict CommonJS, but\n // only CommonJS-like environments that support module.exports,\n // like Node.\n module.exports = factory() : root.svg4everybody = factory();\n}(this, function() {\n /*! svg4everybody v2.1.9 | github.com/jonathantneal/svg4everybody */\n function embed(parent, svg, target) {\n // if the target exists\n if (target) {\n // create a document fragment to hold the contents of the target\n var fragment = document.createDocumentFragment(), viewBox = !svg.hasAttribute(\"viewBox\") && target.getAttribute(\"viewBox\");\n // conditionally set the viewBox on the svg\n viewBox && svg.setAttribute(\"viewBox\", viewBox);\n // copy the contents of the clone into the fragment\n for (// clone the target\n var clone = target.cloneNode(!0); clone.childNodes.length; ) {\n fragment.appendChild(clone.firstChild);\n }\n // append the fragment into the svg\n parent.appendChild(fragment);\n }\n }\n function loadreadystatechange(xhr) {\n // listen to changes in the request\n xhr.onreadystatechange = function() {\n // if the request is ready\n if (4 === xhr.readyState) {\n // get the cached html document\n var cachedDocument = xhr._cachedDocument;\n // ensure the cached html document based on the xhr response\n cachedDocument || (cachedDocument = xhr._cachedDocument = document.implementation.createHTMLDocument(\"\"), \n cachedDocument.body.innerHTML = xhr.responseText, xhr._cachedTarget = {}), // clear the xhr embeds list and embed each item\n xhr._embeds.splice(0).map(function(item) {\n // get the cached target\n var target = xhr._cachedTarget[item.id];\n // ensure the cached target\n target || (target = xhr._cachedTarget[item.id] = cachedDocument.getElementById(item.id)), \n // embed the target into the svg\n embed(item.parent, item.svg, target);\n });\n }\n }, // test the ready state change immediately\n xhr.onreadystatechange();\n }\n function svg4everybody(rawopts) {\n function oninterval() {\n // while the index exists in the live collection\n for (// get the cached index\n var index = 0; index < uses.length; ) {\n // get the current \n var use = uses[index], parent = use.parentNode, svg = getSVGAncestor(parent), src = use.getAttribute(\"xlink:href\") || use.getAttribute(\"href\");\n if (!src && opts.attributeName && (src = use.getAttribute(opts.attributeName)), \n svg && src) {\n if (polyfill) {\n if (!opts.validate || opts.validate(src, svg, use)) {\n // remove the element\n parent.removeChild(use);\n // parse the src and get the url and id\n var srcSplit = src.split(\"#\"), url = srcSplit.shift(), id = srcSplit.join(\"#\");\n // if the link is external\n if (url.length) {\n // get the cached xhr request\n var xhr = requests[url];\n // ensure the xhr request exists\n xhr || (xhr = requests[url] = new XMLHttpRequest(), xhr.open(\"GET\", url), xhr.send(), \n xhr._embeds = []), // add the svg and id as an item to the xhr embeds list\n xhr._embeds.push({\n parent: parent,\n svg: svg,\n id: id\n }), // prepare the xhr ready state change event\n loadreadystatechange(xhr);\n } else {\n // embed the local id into the svg\n embed(parent, svg, document.getElementById(id));\n }\n } else {\n // increase the index when the previous value was not \"valid\"\n ++index, ++numberOfSvgUseElementsToBypass;\n }\n }\n } else {\n // increase the index when the previous value was not \"valid\"\n ++index;\n }\n }\n // continue the interval\n (!uses.length || uses.length - numberOfSvgUseElementsToBypass > 0) && requestAnimationFrame(oninterval, 67);\n }\n var polyfill, opts = Object(rawopts), newerIEUA = /\\bTrident\\/[567]\\b|\\bMSIE (?:9|10)\\.0\\b/, webkitUA = /\\bAppleWebKit\\/(\\d+)\\b/, olderEdgeUA = /\\bEdge\\/12\\.(\\d+)\\b/, edgeUA = /\\bEdge\\/.(\\d+)\\b/, inIframe = window.top !== window.self;\n polyfill = \"polyfill\" in opts ? opts.polyfill : newerIEUA.test(navigator.userAgent) || (navigator.userAgent.match(olderEdgeUA) || [])[1] < 10547 || (navigator.userAgent.match(webkitUA) || [])[1] < 537 || edgeUA.test(navigator.userAgent) && inIframe;\n // create xhr requests object\n var requests = {}, requestAnimationFrame = window.requestAnimationFrame || setTimeout, uses = document.getElementsByTagName(\"use\"), numberOfSvgUseElementsToBypass = 0;\n // conditionally start the interval if the polyfill is active\n polyfill && oninterval();\n }\n function getSVGAncestor(node) {\n for (var svg = node; \"svg\" !== svg.nodeName.toLowerCase() && (svg = svg.parentNode); ) {}\n return svg;\n }\n return svg4everybody;\n});","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// Get a list of your products and pop them into a dropdownlist\nfunction GetProducts() {\n\tvar preselectedId = $('.v12-form').data('selected-id') ? $('.v12-form').data('selected-id') : null;\n\tvar products = V12.getFinanceProducts();\n\tvar ddlProducts = document.getElementById('productsList');\n\tvar productFilterTerms = JSON.parse(document.getElementById('productFilterTerms').value);\n\n\tproducts = products.filter(function (product) {\n\t\tfor (var i = 0; i < productFilterTerms.length; i++) {\n\t\t\tif (product.productId === productFilterTerms[i].productId) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t});\n\t\n\tfor (var i = 0; i < products.length; i++) {\n\t\tif (products[i].deferredPeriod == 0) {\n\t\t\tvar newItem = new Option(products[i].name, products[i].productId);\n\t\t\tif (preselectedId == products[i].productId) {\n\t\t\t\tnewItem.selected = true;\n\t\t\t} else if (products.length > productFilterTerms.length - 1 && i == productFilterTerms.length - 1 && !preselectedId) {\n\t\t\t\tnewItem.selected = true;\n\t\t\t}\n\t\t\tnewItem.setAttribute('data-guid', products[i].productGuid);\n\n\t\t\tif (productFilterTerms.length > 0) {\n\t\t\t\tif (productFilterTerms.find(element => element.productId === products[i].productId)) {\n\t\t\t\t\tddlProducts.appendChild(newItem);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tddlProducts.appendChild(newItem);\n\t\t\t}\n\t\t}\n\t}\n}\n\n// Get details of repayments for the product selected\nfunction CalculateRepayments() {\n\tvar productId = $('#productsList').val(); // selected product\n\t$('#productId').val(productId);\n\t$('#productGuid').val($(\"#productsList option:selected\").data(\"guid\"));\n\t$('#productValue').val($(\"#productsList option:selected\").text());\n\tvar financeProduct = V12.getFinanceProduct(productId); //get the object\n\tvar cashPrice = $('#cashPrice').val();\n\tvar depositFactor = $('#deposit').val();\n\t// var deposit = cashPrice * (depositFactor /100); // 9/1/2018 V12\n\tvar deposit = parseInt(Math.ceil(cashPrice * depositFactor)) / 100; // 9/1/2018 V12\n\tdeposit = parseFloat(deposit.toFixed(2)); // 9/1/2018 V12\n\t$('#cashDeposit').val(deposit);\n\tvar payments = V12.calculate(financeProduct, cashPrice, deposit);\n\t$('#loanAmount').val(payments.loanAmount);\n\tPopulateDescription(payments);\n\t$('#v12_summary').val($('.body.v12 .breakdown').html());\n}\n\nfunction UpdateLoanInfo() {\n\t$('#deposit').val($('#depRange').val());\n\tCalculateRepayments();\n}\n\n// Show repayment plan details in the description\nfunction PopulateDescription(payments) {\n\tvar currency = $('.body.v12').data('currency');\n\t$(\"#lblCashPrice\").html(currency + payments.cashPrice);\n\n\tif (payments.deposit > 0) {\n\t\t$(\"#lblDeposit\").html(currency + payments.deposit);\n\t\t$('#lblDepositNow').html(currency + payments.deposit + ' deposit. ');\n\t\t$('#lblDeposit').css(\"display\", \"\");\n\t\t$('#lblDepositNow').css(\"display\", \"\");\n\t} else {\n\t\t$('#lblDeposit').css(\"display\", \"none\");\n\t\t$('#lblDepositNow').css(\"display\", \"none\");\n\t}\n\n\tif (payments.loanAmount > 0) {\n\t\t$('#lblinstalment').html(currency + payments.loanAmount);\n\t}\t\n\t\t\n\t$(\"#lblAmountCredit\").html(currency + payments.loanAmount);\n\n\tvar repayableText = '';\n\tif (payments.monthsDeferred > 0) {\n\t\trepayableText = 'Non-payment period ' + payments.\n\t\tmonthsDeferred + ' months, followed by ';\n\t}\n\n\tvar $financeText = $('.js-finance-text');\n\n\trepayableText += payments.months + \" months x \" + currency + payments.initialPayments;\n\tif ($financeText.length > 0) {\n\t\tvar financeTextContent = $financeText.html();\n\t\t\n\t\tif (financeTextContent.includes(\"{0}\")) {\n\t\t\tfinanceTextContent = financeTextContent.replace(/\\{0\\}/g, currency + payments.initialPayments);\n\t\t} else {\n\t\t\tfinanceTextContent = financeTextContent.replace(/\\d+(\\.\\d{1,2})?/g, payments.initialPayments);\n\t\t}\n\t\t\n\t\t$financeText.html(financeTextContent);\n\t}\n\n\t$('#lblRepayable').html(repayableText);\n\t$(\"#lblApr\").html(currency + payments.apr);\n\t$(\"#lblAnnualRate\").html(payments.annualRate + \" %\");\n\n\tif (payments.documentFee > 0) {\n\t\t$('#lblArrangementFee').html('Arrangement fee ' + currency + payments.documentFee + '. ');\n\t\t$('#lblArrangementFee').css(\"display\", \"\");\n\t} else {\n\t\t$('#lblArrangementFee').css(\"display\", \"none\");\n\t}\n\n\tif (payments.settlementFee > 0) {\n\t\t$('#lblSettlementFee').html('Settlement fee ' + currency + payments.settlementFee + '. ');\n\t\t$('#lblSettlementFee').css(\"display\", \"\");\n\t} else {\n\t\t$('#lblSettlementFee').css(\"display\", \"none\");\n\t}\n\n\t$(\"#lblTotalRepayable\").html(currency + payments.amountPayable);\n\n\tif (payments.monthsDeferred > 0 && payments.name.indexOf('Buy Now Pay Later') >= 0) {\n\t\t$('#lblBnpl').html('Buy Now Pay Later Option: If you pay the amount of credit plus the settlement fee of ' + currency + payments.settlementFee + ' by the end of the non-payment period, you will pay no interest. If you have not paid the amount of credit in full before the end of the non-payment period the ' + currency +\n\t\tpayments.settlementFee + ' fee will not be payable but interest (at the rate specified above) will be charged on the outstanding credit amount, from the date we told you your agreement was live.');\n\t\t$('#lblBnpl').css(\"display\", \"\");\n\t} else {\n\t\t$('#lblBnpl').css(\"display\", \"none\");\n\t}\n}\n\n// Firing this will loop through your V12 products and grab the product with the lowest\n// possible monthly payments.\nfunction GetLowestMonthlyPayments() {\n\tvar products = V12.getFinanceProducts();\n\tvar lowestMonthlyPayment = 0;\n\tvar lowestMonthlyPaymentProductId = 0;\n\tfor (var i = 0; i < products.length; i++) {\n\t\tvar product = V12.getFinanceProduct(products[i].productId);\n\t\tvar cashPrice = $('#cashPrice').val();\n\t\tvar depositFactor = $('#deposit').val();\n\t\t// var deposit = cashPrice * (depositFactor / 100); // 9/1/2018 V12\n\t\tvar deposit = parseInt(Math.ceil(cashPrice * depositFactor)) / 100; // 9/1/2018 V12\n\t\tdeposit = parseFloat(deposit.toFixed(2)); // 9/12018 V12\n\t\tvar payments = V12.calculate(product, cashPrice, deposit);\n\t\tvar monthlyPayment = payments.initialPayments;\n\n\t\tif (parseFloat(lowestMonthlyPayment) > parseFloat (monthlyPayment) || lowestMonthlyPayment == 0) {\n\t\t\tlowestMonthlyPayment = payments.initialPayments;\n\t\t\tlowestMonthlyPaymentProductId = product.productId;\n\t\t}\n\t}\n\t$(\"#productsList\").val(lowestMonthlyPaymentProductId);\n\tCalculateRepayments();\n}\n\n$(document).ready(function () {\n\tvar v12eligibility = document.getElementById('v12eligibility');\n\tif (!v12eligibility) {\n\t\treturn;\n\t}\n\n\tGetProducts();\n\tCalculateRepayments();\n\n\t$('#productsList').on('change', function () {\n\t\tCalculateRepayments();\n\t});\n\n\t$('#depRange').on(\"input\", function () {\n\t\tUpdateLoanInfo();\n\t});\n\n\t$('#lowestMonthlyPayments').click(function () {\n\t\tGetLowestMonthlyPayments();\n\t});\n\n\t$('#cashPrice, #deposit').keyup(function () {\n\t\tvar cp = $('#cashPrice').val();\n\t\tvar dep = $('#deposit').val();\n\t\t$('#depRange').val(dep);\n\t\tCalculateRepayments();\n\t});\n});\n","require('svg4everybody')({});\n"],"names":[],"sourceRoot":""}