{"version":3,"file":"default/js/afterpay.js","mappings":";;;;;;;;;;AAAa;;AAEb;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;;;;;;;;;;;ACZa;;AAEb;;AAEA;AACA;AACA,WAAW,QAAQ;AACnB;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uDAAuD;AACvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,SAAS;AACT,KAAK;AACL;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,SAAS;AACT;AACA;;AAEA;;;;;;;UCtDA;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;;;;;;;ACtBa;;AAEb,qBAAqB,mBAAO,CAAC,uFAAW;AACxC;AACA;AACA,WAAW,QAAQ;AACnB,WAAW,QAAQ;AACnB,WAAW,QAAQ;AACnB,WAAW,QAAQ;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mCAAmC,gCAAgC;AACnE;;AAEA;AACA;AACA,SAAS;AACT;AACA;;AAEA;AACA,mBAAmB,mBAAO,CAAC,4HAA4B;;AAEvD;;AAEA;AACA;AACA,KAAK;;AAEL;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA,KAAK;;AAEL;AACA;AACA,2BAA2B,iFAAiF;AAC5G;;AAEA;AACA,2BAA2B,iEAAiE;AAC5F;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,mCAAmC,iEAAiE;AACpG;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA,CAAC","sources":["webpack://sfra-startup-kit/./cartridges/app_storefront_base/cartridge/client/default/js/util.js","webpack://sfra-startup-kit/./cartridges/int_afterpay_sfra_6/cartridge/client/default/js/afterpay/afterpayContent.js","webpack://sfra-startup-kit/webpack/bootstrap","webpack://sfra-startup-kit/./cartridges/int_afterpay_sfra_6/cartridge/client/default/js/afterpay.js"],"sourcesContent":["'use strict';\n\nmodule.exports = function (include) {\n if (typeof include === 'function') {\n include();\n } else if (typeof include === 'object') {\n Object.keys(include).forEach(function (key) {\n if (typeof include[key] === 'function') {\n include[key]();\n }\n });\n }\n};\n","'use strict';\n\nvar afterpay;\n\n/**\n * Populates afterpay popup modal\n * @param {jquery} e - jquery element\n */\nfunction openAfterpayModal(e) {\n e.preventDefault();\n\n var url = $(this).prop('href');\n\n $.get(url, function (data) {\n if ($('#afterpayModal').length) {\n $('#afterpayModal').remove();\n }\n /* eslint-disable operator-linebreak */\n var htmlString = '' +\n '
' +\n '
' +\n '' +\n '
' +\n '
' +\n ' ' +\n '
' +\n '
' + data + '
' +\n '
' +\n '
' +\n '
';\n /* eslint-enable operator-linebreak */\n $('body').append(htmlString);\n $('body').addClass('modal-open');\n $('#afterpayModal').addClass('show');\n\n $('#overview-container-circles img').on('load', function () {\n afterpay.popupVerticalCenter();\n });\n });\n}\n\nafterpay = {\n init: function () {\n $('div[itemid=\"#product\"], .product-detail, .cart-page, .tab-content').on('click', '.afterpay-link a', openAfterpayModal);\n\n $('body').on('click', '#afterpayModal .modal-header button', function () {\n $('#afterpayModal').remove();\n $('body').removeClass('modal-open');\n });\n }\n};\n\nmodule.exports = afterpay;\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](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","'use strict';\n\nvar processInclude = require('base/util');\n/**\n * Gets Widget HTML from AfterPay API\n * @param {string} updatedProductID - product ID\n * @param {number} updatedPrice - product price\n * @param {string} className - HTML class name\n * @param {jquery} $productContainer - DOM container for product\n */\nfunction getWidget(updatedProductID, updatedPrice, className, $productContainer) {\n var getUpdatedWidgetUrl = $('.updated-widget').val();\n var queryString = '?productID=' + updatedProductID + '&updatedPrice=' + updatedPrice + '&className=' + className;\n $.ajax({\n url: getUpdatedWidgetUrl + queryString,\n method: 'GET',\n success: function (data) {\n if (data.updatedWidget) {\n if (typeof $productContainer !== 'undefined') {\n $productContainer.find('.afterpay-widget').html(data.updatedWidget);\n $productContainer.find('.afterpay-widget').show();\n } else if (typeof $productContainer === 'undefined') {\n $('.afterpay-widget').html(data.updatedWidget);\n $('.afterpay-widget').show();\n }\n }\n $('#afterpay-express-pdp-button').toggleClass('afterpay-hide', !data.apApplicable);\n }\n });\n}\n\n/**\n * @description Update widget for PDP specifically\n */\nfunction updatePpdWidget() {\n // Assuming the element with the data-pid attribute is within the product detail container\n const productID = $('.product-detail').attr('data-pid');\n var productPrice = $('.prices-add-to-cart-actions .prices .price .sales .value').attr('content');\n var productContainer = $('.product-detail');\n\n getWidget(productID, productPrice, 'pdp-afterpay-message', productContainer);\n}\n\n/**\n * @description Update Pickup Store\n */\nfunction updateStorePickupState() {\n var getCartStatusUrl = $('#afterpay-express-url-cartstatus').val();\n if (getCartStatusUrl) {\n $.ajax({\n url: getCartStatusUrl,\n method: 'GET',\n success: function (data) {\n if (data.instorepickup) {\n $('#afterpay-express-storepickup').val(data.instorepickup.toString());\n initAfterpay({ pickupflag: data.instorepickup });\n }\n\n $('#afterpay-express-button').toggleClass('afterpay-hide', !data.apApplicable);\n }\n });\n }\n}\n\n$(document).ready(function () {\n processInclude(require('./afterpay/afterpayContent'));\n\n var cartTotal = '';\n\n $('body').on('product:afterAttributeSelect', function () {\n updatePpdWidget();\n });\n\n $(document).ajaxStart(function () {\n if (!$('.afterpay-widget').hasClass('loading')) {\n $('.afterpay-widget').addClass('loading');\n\n if ($('.afterpay-widget .cart-afterpay-message').length) {\n cartTotal = $('.grand-total').text();\n }\n }\n\n if (!$('#afterpay-express-url-cartstatus').hasClass('loading')) {\n $('#afterpay-express-url-cartstatus').addClass('loading');\n }\n });\n\n $('#afterpay-continue-finalize-button').on('click', function () {\n window.location.href = $('#afterpayurl-continuefinalize').val();\n });\n\n if (typeof initAfterpay === 'function') {\n if ($('#afterpay-express-pdp-button').length > 0) {\n initAfterpay({ pickupflag: 'false', commenceDelay: 200, target: '#afterpay-express-pdp-button' });\n }\n\n if ($('#afterpay-express-button').length > 0) {\n initAfterpay({ pickupflag: $('#afterpay-express-storepickup').val() === 'true' });\n }\n }\n\n $(document).ajaxComplete(function () {\n var newCartTotal = $('.grand-total').text();\n\n if ($('.afterpay-widget').hasClass('loading')) {\n $('.afterpay-widget').removeClass('loading');\n\n if ($('.afterpay-widget').length && cartTotal !== newCartTotal) {\n getWidget(null, null, 'cart-afterpay-message');\n }\n }\n\n // make sure we call initAfterpay after the minicart loads so checkout click will work\n if ($('.minicart #afterpay-express-button').length > 0) {\n var cnt = 0;\n var sid = setInterval(function () {\n if (typeof initAfterpay === 'function' && typeof AfterPay !== 'undefined') {\n clearInterval(sid);\n initAfterpay({ pickupflag: $('#afterpay-express-storepickup').val() === 'true' });\n }\n if (cnt === 10) {\n clearInterval(sid);\n }\n ++cnt;\n }, 500);\n }\n\n // On pdp page, if a store is selected, disable buy now express checkout button.\n if ($('.store-name').length > 0) {\n $('#afterpay-express-pdp-button').addClass('afterpay-hide');\n }\n\n if ($('.cart-page').length > 0) {\n // Just put a loading class on the url input so this does not get called recursively\n if ($('#afterpay-express-url-cartstatus').hasClass('loading')) {\n updateStorePickupState();\n $('#afterpay-express-url-cartstatus').removeClass('loading');\n }\n }\n\n if ($('div').hasClass('popover popover-bottom show')) {\n if ($('#afterpay-express-url-cartstatus').hasClass('loading')) {\n updateStorePickupState();\n $('#afterpay-express-url-cartstatus').removeClass('loading');\n }\n }\n });\n\n // initialize\n});\n"],"names":[],"sourceRoot":""}