{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./cartridges/int_catch_sfra/cartridge/client/default/js/catch.js","webpack:///./cartridges/int_catch_sfra/cartridge/client/default/js/catch/helper/catchHelper.js","webpack:///./cartridges/int_catch_sfra/cartridge/client/default/js/catchInitOnPDP.js","webpack:///./sfra/cartridges/app_storefront_base/cartridge/client/default/js/util.js"],"names":[],"mappings":";QAAA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;;QAGA;QACA;;;;;;;;;;;;;AClFa;;AAEb,qBAAqB,mBAAO,CAAC,4FAAW;;AAExC;AACA,mBAAmB,mBAAO,CAAC,mGAAkB;AAC7C,CAAC;;;;;;;;;;;;;ACNY;;AAEb;AACA;AACA,YAAY,OAAO;AACnB,aAAa,OAAO;AACpB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,QAAQ;AACnB;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,8CAA8C;AAC9C;AACA,SAAS;AACT;AACA;AACA;AACA;AACA,SAAS;AACT;AACA,SAAS;;AAET;AACA;AACA;AACA;AACA;AACA,iBAAiB;AACjB,aAAa;AACb;AACA;AACA;AACA,iBAAiB;AACjB;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA,WAAW,QAAQ;AACnB,WAAW,OAAO;AAClB;AACA;AACA,gDAAgD;AAChD;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,QAAQ;AACnB,WAAW,OAAO;AAClB;AACA;AACA,gDAAgD;AAChD;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,QAAQ;AACnB,WAAW,iBAAiB;AAC5B,WAAW,QAAQ;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA,WAAW,QAAQ;AACnB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB,aAAa,OAAO;AACpB;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,QAAQ;AACnB;AACA;AACA,4CAA4C;AAC5C;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;ACzQa;;AAEb,kBAAkB,mBAAO,CAAC,uHAA4B;;AAEtD;AACA;;;;;;;;;;;;;ACLa;;AAEb;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA,SAAS;AACT;AACA","file":"default/js/catch.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./cartridges/int_catch_sfra/cartridge/client/default/js/catch.js\");\n","'use strict';\n\nvar processInclude = require('base/util');\n\n$(document).ready(function () {\n processInclude(require('./catchInitOnPDP'));\n});\n","'use strict';\n\n/**\n * @description Function forms object with prefilled data for Catch checkout widget\n * @param {Object} data - data passed from ajax request\n * @returns {Object} - object with prefilled data\n */\nfunction getCatchPrefilledData(data) {\n var prefilledData;\n\n if (!data.customer.registeredUser) {\n prefilledData = {\n userPhone: data.order.billing.billingAddress.address.phone,\n userName: data.order.billing.billingAddress.address.firstName + ' ' + data.order.billing.billingAddress.address.lastName,\n userEmail: data.order.orderEmail\n };\n } else {\n prefilledData = {\n userPhone: data.customer.profile.phone,\n userName: data.customer.profile.firstName + ' ' + data.customer.profile.lastName,\n userEmail: data.customer.profile.email\n };\n }\n\n return prefilledData;\n}\n\n/**\n * @description Function initializes Catch SDK\n * @param {string} pageType - type of page where catch SDK is initialized\n * @param {string} catchCheckoutID - Catch checkout ID\n * @param {Object} option - specifying a value for options\n * @param {boolean} isCatchVirtualCard - Catch Virtual card checkout\n */\nfunction initializeCatchSDK(pageType, catchCheckoutID, option, isCatchVirtualCard) {\n var publicKey = $('.catch-data').data('key');\n\n if (!publicKey) {\n return;\n }\n\n try {\n var result = catchjs.init(publicKey, { // eslint-disable-line no-undef\n pageType: pageType || 'unknown'\n }).then(function (promise) {\n if ($('#catch-payment-tab').length > 0) {\n $('#catch-payment-tab').removeClass('catch-tab-hidden');\n }\n return promise;\n }).catch(function () {\n return;\n });\n\n if (catchCheckoutID && option) {\n if (isCatchVirtualCard) {\n result.then(function (catchHandle) {\n window.catchHandle = catchHandle;\n catchHandle.openVirtualCardCheckout(catchCheckoutID, option);\n });\n } else {\n result.then(function (catchHandle) {\n window.catchHandle = catchHandle;\n catchHandle.openCheckout(catchCheckoutID, option);\n });\n }\n }\n } catch (e) {\n return;\n }\n}\n\n/**\n * @description Function shows widget on the page\n * @param {Element} widget - widget element\n * @param {string} className - class name to remove\n*/\nfunction showWidget(widget, className) {\n className = className || 'callout-disabled'; // eslint-disable-line no-param-reassign\n if (widget.length > 0 && widget.hasClass(className)) {\n widget.removeClass(className);\n }\n}\n\n/**\n * @description Function hides widget on the page\n * @param {Element} widget - widget element\n * @param {string} className - class name to add\n*/\nfunction hideWidget(widget, className) {\n className = className || 'callout-disabled'; // eslint-disable-line no-param-reassign\n if (widget.length > 0 && !widget.hasClass(className)) {\n widget.addClass(className);\n }\n}\n\n/**\n * @description Function sets price attribute value to callout widget\n * @param {Element} element - widget element\n * @param {Element | number} priceContainter - price element\n * @param {Element} qauntityContainer - quantity container element\n */\nfunction setPrice(element, priceContainter, qauntityContainer) {\n var CATCH_PRICE_LIMIT = 500000;\n var qauntity = qauntityContainer ? +qauntityContainer.attr('value') || 1 : 1;\n var widgetPrice =\n priceContainter instanceof jQuery\n ? (+priceContainter.attr('content') * 100).toFixed()\n : priceContainter;\n\n element.attr('price', ' ');\n element.attr('price', widgetPrice * qauntity);\n\n if (widgetPrice > CATCH_PRICE_LIMIT) {\n hideWidget(element, 'catch-hidden');\n } else {\n showWidget(element, 'catch-hidden');\n }\n}\n\n/**\n * @description Function gets element that contains available product quantity\n * @param {Element} parent - parent element\n * @returns {Element} - quantity container element\n */\nfunction getQuantityContainerElement(parent) {\n return parent.find('.quantity-select > option:selected');\n}\n\n/**\n * @description Function clears price value from dollar signs and dots\n * @param {string} price - price value\n * @returns {number} - price in cents\n */\nfunction getPriceInCents(price) {\n return +price.replace(/[^\\d]*/g, '');\n}\n\n/**\n * @description Function sets items attribute value to callout widget\n * @param {string} itemsData - stringified items data\n * @param {Element} widgets - callout widgets\n */\nfunction setItemsAttribute(itemsData, widgets) {\n widgets = widgets || $('catch-callout'); // eslint-disable-line no-param-reassign\n widgets.attr('items', itemsData);\n}\n\n/**\n * @description Function updates widget's price attribute value on cart and minicart\n * @param {string} cartTotals - cart totals\n */\nfunction updateCartWidgets(cartTotals) {\n var miniCartWidget = $('.callout-mini-cart-wrapper catch-callout');\n var cartTotalsWidget = $('.totals catch-callout');\n\n setPrice(miniCartWidget, getPriceInCents(cartTotals.subTotal));\n if (cartTotalsWidget.length) {\n setPrice(cartTotalsWidget, getPriceInCents(cartTotals.grandTotal));\n }\n setItemsAttribute(cartTotals.catchItems, $(miniCartWidget, cartTotalsWidget));\n}\n\n/**\n * @description Function updates widget's items attribute value on PDP\n * @param {Object} response - server's response with product data after product attribute was changed on PDP\n */\nfunction updateItemsAttributePDP(response) {\n var widget = response.container.find('catch-callout');\n var itemsAttributeCurrentData = JSON.parse(widget.attr('items'))[0];\n var productData = response.data.product;\n var productPriceData = productData.price.sales ? productData.price.sales : productData.price.min.sales;\n\n var item = {\n name: productData.productName,\n sku: productData.id,\n quantity: productData.selectedQuantity,\n price: {\n amount: productPriceData.value * 100,\n currency: productPriceData.currency // String. Currency in ISO_4217 format\n },\n category: itemsAttributeCurrentData.category\n };\n\n var imageItems = productData.images.small;\n if (imageItems && imageItems.length > 0) {\n item.image_url = imageItems[0].absURL;\n }\n\n setItemsAttribute(JSON.stringify([item]), widget);\n}\n\n\n/**\n * @description Function handles changes of the price on PDP page\n */\nfunction handleWidgetPriceAttributeValue() {\n var priceContainter;\n var widgets = $('catch-callout');\n\n var isSetProductPage = $('.product-detail.product-set-detail').length > 0;\n var isCartOrCheckoutPage = $('.grand-total').length > 0;\n\n if (isCartOrCheckoutPage) {\n priceContainter = $('.grand-total');\n var widgetPrice = (priceContainter.text()).replace(/[^\\d]*/g, '');\n setPrice(widgets, widgetPrice);\n\n var paymentWidget = $('catch-payment-method');\n if (paymentWidget.length > 0) {\n setPrice(paymentWidget, widgetPrice);\n }\n } else if (isSetProductPage) {\n var widgetCollection = widgets;\n\n if ($('.callout-mini-cart-wrapper catch-callout').length > 0) {\n widgetCollection = widgets.slice(1);\n }\n\n widgetCollection.each(function () {\n var widget = $(this);\n var parents = widget.parents('.row');\n var closestPriceElement = parents.find('.sales > .value');\n\n if (closestPriceElement.length > 1) {\n closestPriceElement = closestPriceElement.first();\n }\n setPrice(widget, closestPriceElement, getQuantityContainerElement(parents));\n });\n } else {\n if ($('.callout-mini-cart-wrapper catch-callout').length > 0) {\n widgets = widgets.slice(1);\n }\n\n priceContainter = widgets.parents('.row:last').find('.attributes-container .selected .sales > .value');\n setPrice(widgets, priceContainter, getQuantityContainerElement(parent));\n }\n}\n\n/**\n * @description Function initializes price attribute value handling for Catch widgets\n */\nfunction onWidgetPriceAttributeChange() {\n var isPrerenderedPrice;\n if ($('.grand-total').length > 0) {\n isPrerenderedPrice = false;\n } else if ($('.grand-total-sum').length > 0) {\n isPrerenderedPrice = true;\n } else {\n isPrerenderedPrice = false;\n }\n\n if (!isPrerenderedPrice) {\n handleWidgetPriceAttributeValue();\n }\n}\n\nmodule.exports = {\n getCatchPrefilledData: getCatchPrefilledData,\n initializeCatchSDK: initializeCatchSDK,\n onWidgetProductPriceChange: onWidgetPriceAttributeChange,\n updateCartWidgets: updateCartWidgets,\n showWidget: showWidget,\n hideWidget: hideWidget,\n setItemsAttribute: setItemsAttribute,\n updateItemsAttributePDP: updateItemsAttributePDP\n};\n","'use strict';\n\nvar catchHelper = require('./catch/helper/catchHelper');\n\ncatchHelper.onWidgetProductPriceChange();\ncatchHelper.initializeCatchSDK('product');\n","'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"],"sourceRoot":""}