{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./cartridges/app_schuurman_sooco/cartridge/client/default/js/einstein-recommendations.js"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","getEinsteinUtils","einsteinUtils","window","CQuotient","getCQUserId","getCQCookieId","processRecommendationsTile","parentElement","anchorsArray","einsteinParameters","dataset","recommender","params","userId","cookieId","ccver","recommendationsReceived","einsteinResponse","recommendedProducts","recs","length","template","components","map","recommendedProduct","tiledefinition","model","type","id","url","URL","productLoadUrl","$","ajax","href","dataType","data","JSON","stringify","limit","success","innerHTML","trigger","parent","error","e","document","getElementById","containerId","remove","fillEinsteinDomElement","anchors","getRecs","clientId","widgets","push","recommenderName","parameters","callback","addEventListener","setTimeout","Array","from","querySelectorAll","forEach","primaryProductId","sku","secondaryProductId","alternativeGroupType","alt_id","alternativeGroupId","createProductAnchor","loadProductRecommendations","categoryId","createCategoryAnchor","loadCategoryRecommendations","loadNoAnchorRecommendations"],"mappings":"aACE,IAAIA,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUC,QAGnC,IAAIC,EAASJ,EAAiBE,GAAY,CACzCG,EAAGH,EACHI,GAAG,EACHH,QAAS,IAUV,OANAI,EAAQL,GAAUM,KAAKJ,EAAOD,QAASC,EAAQA,EAAOD,QAASF,GAG/DG,EAAOE,GAAI,EAGJF,EAAOD,QAKfF,EAAoBQ,EAAIF,EAGxBN,EAAoBS,EAAIV,EAGxBC,EAAoBU,EAAI,SAASR,EAASS,EAAMC,GAC3CZ,EAAoBa,EAAEX,EAASS,IAClCG,OAAOC,eAAeb,EAASS,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhEZ,EAAoBkB,EAAI,SAAShB,GACX,oBAAXiB,QAA0BA,OAAOC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BxC,KAAMlB,EAAmB2D,qBAAsBC,OAAQ5D,EAAmB6D,qBAR/DC,CAAoBhE,QAzB1HiE,GAwCR,WACI,IAAIvE,EAAgBD,IACpB,GAAIC,EAAe,CACW4D,MAAMC,KAAKhB,SAASiB,iBAAiB,uCAC3CC,SAAQ,SAAAzD,GAAa,OAAID,EAA2BC,EAAeN,EAM/F,SAA8BM,GAE1B,MAAO,CAAC,CAAEqB,GADerB,EAAcG,QACN+D,aARyEC,CAAqBnE,QA3C3HoE,GA0DR,WACI,IAAI1E,EAAgBD,IACpB,GAAIC,EAAe,CACW4D,MAAMC,KAAKhB,SAASiB,iBAAiB,uCAC3CC,SAAQ,SAAAzD,GAAa,OAAID,EAA2BC,EAAeN,OA7DvF2E,KACD","file":"app_schuurman_sooco/cartridge/static/default/js/einstein-recommendations.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 = 581);\n","document.addEventListener(\"DOMContentLoaded\", function() {\n setTimeout(function(){\n loadProductRecommendations();\n loadCategoryRecommendations();\n loadNoAnchorRecommendations();\n }, 1000);\n});\n\n/**\n * Validates and Return the cquotient namespace provided by the commerce cloud platform\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 * Gets all product placeholder elements, which hold einstein recommendations queries the details from the \n * einstein engine and feeds them back to the dom element\n */\nfunction loadProductRecommendations() {\n var einsteinUtils = getEinsteinUtils();\n if (einsteinUtils) {\n var recommendationTiles = Array.from(document.querySelectorAll('.einstein-product-recommendations'));\n recommendationTiles.forEach(parentElement => processRecommendationsTile(parentElement, einsteinUtils, createProductAnchor(parentElement)));\n }\n}\n/**\n * Processes a recommendation tile, with an already initialized product specific anchors array\n */\nfunction createProductAnchor(parentElement) {\n var einsteinParameters = parentElement.dataset;\n return [{ id: einsteinParameters.primaryProductId, sku: einsteinParameters.secondaryProductId, type: einsteinParameters.alternativeGroupType, alt_id: einsteinParameters.alternativeGroupId }];\n}\n\n/**\n * Gets all category placeholder elements, which hold einstein recommendations queries the details from the \n * einstein engine and feeds them back to the dom element\n */\nfunction loadCategoryRecommendations() {\n var einsteinUtils = getEinsteinUtils();\n if (einsteinUtils) {\n var recommendationTiles = Array.from(document.querySelectorAll('.einstein-category-recommendations'));\n recommendationTiles.forEach(parentElement => processRecommendationsTile(parentElement, einsteinUtils, createCategoryAnchor(parentElement)));\n }\n}\n/**\n * Rerieves data attributes from parent element and converts to gretel compatible recommenders array\n */\nfunction createCategoryAnchor(parentElement) {\n var einsteinParameters = parentElement.dataset;\n return [{ id: einsteinParameters.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 loadNoAnchorRecommendations() {\n var einsteinUtils = getEinsteinUtils();\n if (einsteinUtils) {\n var recommendationTiles = Array.from(document.querySelectorAll('.einstein-noanchor-recommendations'));\n recommendationTiles.forEach(parentElement => processRecommendationsTile(parentElement, einsteinUtils));\n }\n}\n\n/**\n * Processes a recommendation tile, with an already initialized category specific anchors array\n */\nfunction processRecommendationsTile(parentElement, einsteinUtils, anchorsArray) {\n var einsteinParameters = parentElement.dataset;\n var recommender = einsteinParameters.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 function recommendationsReceived(einsteinResponse) {\n fillEinsteinDomElement(einsteinResponse, parentElement);\n }\n\n if (einsteinUtils.getRecs) {\n einsteinUtils.getRecs(einsteinUtils.clientId, recommender, params, recommendationsReceived);\n } else {\n einsteinUtils.widgets = einsteinUtils.widgets || [];\n einsteinUtils.widgets.push({\n recommenderName : einsteinParameters.recommender,\n parameters : params,\n callback : recommendationsReceived\n });\n }\n}\n\n/**\n * Renders the einstein response into a given dom element\n */\nfunction fillEinsteinDomElement(einsteinResponse, parentElement) {\n var recommendedProducts = einsteinResponse[parentElement.dataset.recommender].recs;\n \n if (recommendedProducts && recommendedProducts.length > 0) {\n var template = parentElement.dataset.template;\n var components = [];\n var components = recommendedProducts.map(recommendedProduct => {\n var tiledefinition = {};\n tiledefinition.template = template;\n tiledefinition.model = {type: 'product', id : recommendedProduct.id};\n return tiledefinition;\n });\n var url = new URL(parentElement.dataset.productLoadUrl);\n $.ajax({\n url: url.href,\n type: 'get',\n dataType: 'html',\n data: {\n components: JSON.stringify(components),\n limit: parentElement.dataset.limit\n },\n success: function (data) {\n if (data) {\n parentElement.innerHTML = data;\n $('body').trigger('einstein:loaded', { parent: parentElement });\n $('body').trigger(\"calculateWaardechequePrices\");\n }\n },\n error: function (e) {\n // In case of error remove the container and its title.\n var container = document.getElementById(parentElement.dataset.containerId);\n container.remove();\n }\n });\n }\n}"],"sourceRoot":""}