{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./cartridges/app_custom_core/cartridge/client/default/js/einsteinCarousel.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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB;AACrB;AACA;AACA;AACA;AACA,yBAAyB;AACzB;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA,SAAS;AACT;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,MAAM;AACjB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,cAAc,OAAO;AACrB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,KAAK;AACL,4DAA4D;AAC5D;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA,WAAW,OAAO;AAClB,aAAa,MAAM;AACnB;AACA;AACA,aAAa,wCAAwC;AACrD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA,SAAS;AACT;AACA;;AAEA;AACA;AACA,CAAC","file":"default/js/einsteinCarousel.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/app_custom_core/cartridge/client/default/js/einsteinCarousel.js\");\n","'use strict';\n\n// Opciones slider\nvar optionsType =\n{\n dots : false,\n arrows : true,\n infinite : true,\n vertical : false,\n slidesToShow : 4,\n slidesToScroll : 1,\n responsive : [{\n breakpoint : 1200,\n settings : {\n slidesToShow : 3,\n slidesToScroll : 3,\n arrows : true\n }\n },\n {\n breakpoint : 991,\n settings : {\n slidesToShow : 3,\n slidesToScroll : 3,\n arrows : true\n }\n },\n {\n breakpoint : 768,\n settings : {\n slidesToShow : 2,\n slidesToScroll : 1,\n arrows : true\n }\n },\n {\n breakpoint : 500,\n settings : {\n slidesToShow : 2,\n slidesToScroll : 1,\n arrows : true\n }\n }]\n};\n\n/**\n * Validates and Return the cquotient namespace provided by the commerce cloud platform\n * @returns {Object} - einsteinUtils or null\n */\nfunction getEinsteinUtils() {\n var einsteinUtils = window.CQuotient;\n if (einsteinUtils && (typeof einsteinUtils.getCQUserId === 'function') && (typeof einsteinUtils.getCQCookieId === 'function')) {\n return einsteinUtils;\n }\n return null;\n}\n\n/**\n * fills in the carousel with product tile html objects\n * @param {string} einsteinResponse string html for product tiles\n * @param {jQuery} $parentElement parent element where recommendations will show.\n */\nfunction fillDomElement(einsteinResponse, $parentElement) {\n var recommender = $parentElement.data('recommender');\n var recommendedProducts = einsteinResponse[recommender].recs;\n if (recommendedProducts && recommendedProducts.length > 0) {\n var template = $parentElement.data('template');\n var quickView = $parentElement.data('quickview');\n var showButtons = $parentElement.data('showbuttons');\n var showRibbons = $parentElement.data('showribbons');\n var hasSlick = $parentElement.data('hascarousel');\n var suffix = $parentElement.data('preffix');\n var components = [];\n components = recommendedProducts.map(function (recommendedProduct) {\n var tiledefinition = {};\n tiledefinition.template = template;\n tiledefinition.quickView = quickView;\n tiledefinition.showButtons = showButtons;\n tiledefinition.showRibbons = showRibbons;\n tiledefinition.model = {\n type : 'product',\n id : recommendedProduct.id\n };\n return tiledefinition;\n });\n\n var url = new URL($parentElement.data('product-load-url'));\n url.searchParams.append('recommender', recommender);\n url.searchParams.append('components', JSON.stringify(components));\n $.ajax({\n url : url.href,\n type : 'get',\n dataType : 'html',\n success : function (html) {\n var idInner = '#' + $parentElement.data('id');\n var einsteinCarrousel = $(idInner);\n if (einsteinCarrousel.length > 0) {\n einsteinCarrousel.html(html);\n $(idInner + ' script').each(function () {\n var scriptElement = $(this).clone();\n $(this).remove();\n scriptElement.insertAfter(idInner);\n });\n $('#recommendationTypeEinstein1-' + suffix + ' h3.title').removeClass('d-none');\n if (hasSlick) {\n if (components.length >= optionsType.slidesToShow) {\n einsteinCarrousel.slick(optionsType);\n } else {\n einsteinCarrousel.slick();\n }\n }\n }\n },\n error: function () {\n $parentElement.spinner().stop();\n }\n });\n }\n}\n\n/**\n * Processes a recommendation tile, with an already initialized category specific anchors array\n * @param {jQuery} $parentElement parent element where recommendations will show.\n * @param {Object} einsteinUtils cquotient object\n * @param {Array} anchorsArray array of objects representing anchors\n */\nfunction processRecommendationsTile($parentElement, einsteinUtils, anchorsArray) {\n var recommender = $parentElement.data('recommender');\n\n var params = {\n userId : einsteinUtils.getCQUserId(),\n cookieId : einsteinUtils.getCQCookieId(),\n ccver : '1.01'\n };\n\n if (anchorsArray) {\n params.anchors = anchorsArray;\n }\n\n /**\n * Processes a recommendation responses\n * @param {Object} einsteinResponse cquotient object\n */\n function recommendationsReceived(einsteinResponse) {\n fillDomElement(einsteinResponse, $parentElement);\n $parentElement.spinner().stop();\n }\n\n if (einsteinUtils.getRecs) {\n einsteinUtils.getRecs(einsteinUtils.clientId, recommender, params, recommendationsReceived);\n } else {\n einsteinUtils.widgets = einsteinUtils.widgets || []; // eslint-disable-line no-param-reassign\n einsteinUtils.widgets.push({\n recommenderName : recommender,\n parameters : params,\n callback : recommendationsReceived\n });\n }\n}\n\n/**\n * Processes a recommendation tile, with an already initialized product specific anchors array\n * @param {jQuery} $parentElement parent element where recommendations will show.\n * @returns {Array} - containing an anchor object\n */\nfunction createProductAnchor($parentElement) {\n return [{\n id : $parentElement.data('primaryProductId'),\n sku : $parentElement.data('secondaryProductId'),\n type : $parentElement.data('alternativeGroupType'),\n alt_id : $parentElement.data('alternativeGroupId')\n }];\n}\n\n/**\n * Rerieves data attributes from parent element and converts to gretel compatible recommenders array\n * @param {jQuery} $parentElement parent element where recommendations will show.\n * @returns {Array} - containing an anchor object\n */\nfunction createCategoryAnchor($parentElement) {\n return [{ id: $parentElement.data('categoryId') }];\n}\n\n/**\n * Gets all placeholder elements, which hold einstein recommendations queries the details from the\n * einstein engine and feeds them back to the dom element\n */\nfunction loadRecommendations() {\n var einsteinUtils = getEinsteinUtils();\n if (einsteinUtils) {\n var $recommendationTiles = $('.einstein-carousel');\n $recommendationTiles.each(function () {\n var $parentElement = $(this);\n $parentElement.spinner().start();\n if ($(this).closest('.experience-einstein-CarouselProduct').length) {\n return processRecommendationsTile($parentElement, einsteinUtils, createProductAnchor($parentElement));\n } else if ($(this).closest('.experience-einstein-CarouselCategory').length) {\n return processRecommendationsTile($parentElement, einsteinUtils, createCategoryAnchor($parentElement));\n }\n return processRecommendationsTile($parentElement, einsteinUtils);\n });\n }\n}\n\n$(document).ready(function () {\n loadRecommendations();\n});\n"],"sourceRoot":""}