{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///../b2c-commerce-toolkit-for-grocery/fs-grocery-project-code/cartridges/app_sunnie_foods/cartridge/client/default/js/product/wishlistHeart.js","webpack:///../b2c-commerce-toolkit-for-grocery/salesforce-storefront-reference-architecture/cartridges/app_storefront_base/cartridge/client/default/js/util.js","webpack:///./cartridges/pluggin_variable_weight/cartridge/client/default/js/product/tile.js","webpack:///./cartridges/pluggin_variable_weight/cartridge/client/default/js/search.js","webpack:///./cartridges/pluggin_variable_weight/cartridge/client/default/js/search/search.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;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;AACA;AACA,iEAAiE,OAAO,IAAI,SAAS;;AAErF;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB;AACjB;AACA;AACA,iBAAiB;AACjB;AACA;AACA,iBAAiB;AACjB,aAAa;AACb,SAAS;AACT,KAAK;AACL;;;;;;;;;;;;;AC9Da;;AAEb;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;;;;;;;;;;;;ACZA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oDAAoD,QAAQ;AAC5D;AACA,iGAAiG,QAAQ;AACzG,aAAa;AACb,sDAAsD,QAAQ;AAC9D;AACA,SAAS;AACT;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB,YAAY,OAAO;AACnB;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB,YAAY,OAAO;AACnB;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB,YAAY,OAAO;AACnB;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB;AACA,YAAY,OAAO;AACnB;AACA;AACA;;AAEA;AACA;;AAEA,YAAY;AACZ;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA,0BAA0B;AAC1B;AACA;AACA;AACA,6BAA6B,EAAE,mBAAmB;AAClD,wBAAwB,UAAU;AAClC,2BAA2B,aAAa;AACxC,gCAAgC,kBAAkB;AAClD;AACA,4BAA4B,cAAc;AAC1C,2BAA2B,8BAA8B;AACzD,wCAAwC,0BAA0B;AAClE;AACA;AACA;AACA,gCAAgC,wBAAwB;AACxD;AACA,mDAAmD;AACnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA,+DAA+D,YAAY;AAC3E;AACA,SAAS;;AAET;AACA;AACA,SAAS;AACT;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB;AACjB;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,iBAAiB;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA,SAAS;AACT;AACA;;AAEA;AACA;AACA;AACA,WAAW,QAAQ;AACnB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;;AAEA;AACA;AACA,cAAc,QAAQ;AACtB;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,YAAY;AACZ;AACA;AACA;AACA,QAAQ;AACR;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;;AAER;AACA;AACA;AACA,6CAA6C,iCAAiC;AAC9E;AACA,QAAQ;AACR,IAAI;;AAEJ;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB;AACrB;AACA;AACA;AACA,iBAAiB;AACjB;AACA,SAAS;AACT,KAAK;AACL;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA,qCAAqC;AACrC,iCAAiC;AACjC;AACA;AACA;AACA;AACA;;AAEA;;AAEA,2CAA2C,kBAAkB;AAC7D;AACA;AACA,iCAAiC;AACjC;AACA;AACA;AACA;AACA,yBAAyB;;AAEzB;;AAEA;AACA;AACA;;AAEA;AACA,6BAA6B;;;AAG7B;;AAEA,2CAA2C,kBAAkB;AAC7D;AACA;AACA,iCAAiC;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB;AACrB;AACA;AACA;AACA,iBAAiB;AACjB;AACA,SAAS;AACT,KAAK;AACL;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;AACA;;;;;;;;;;;;;ACvda;;AAEb,qBAAqB,mBAAO,CAAC,sKAAW;;AAExC;AACA,mBAAmB,mBAAO,CAAC,0GAAiB;AAC5C;AACA,mBAAmB,mBAAO,CAAC,wLAAoC;AAC/D,mBAAmB,mBAAO,CAAC,wGAAgB;AAC3C,CAAC;;;;;;;;;;;;;ACTY;;AAEb,iBAAiB,mBAAO,CAAC,yGAAiB;;AAE1C;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,YAAY;AACZ;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA,a;AACA,SAAS;AACT,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;;AAEL;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,uBAAuB,0BAA0B;AACjD;AACA;AACA;AACA;AACA,iBAAiB;AACjB;AACA;AACA;AACA,aAAa;AACb,SAAS;AACT,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,uBAAuB,2BAA2B;AAClD;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB;AACjB;AACA;AACA;AACA,aAAa;AACb,SAAS;AACT,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB;AACrB;AACA;AACA;AACA;AACA,qBAAqB;AACrB;AACA;AACA;AACA,iBAAiB;AACjB,aAAa;AACb,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL","file":"default/js/search.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/pluggin_variable_weight/cartridge/client/default/js/search.js\");\n","/**\n * appends params to a url\n * @param {string} data - data returned from the server's ajax call\n * @param {Object} icon - icon that was clicked to add a product to the wishlist\n */\nfunction displayMessageAndChangeIcon(data, icon) {\n $.spinner().stop();\n let status;\n if (data.success) {\n status = 'alert-success';\n if (icon.hasClass('fa-heart-o')) {\n icon.removeClass('fa-heart-o').addClass('fa-heart');\n }\n } else {\n status = 'alert-danger';\n }\n\n if ($('.add-to-wishlist-messages').length === 0) {\n $('body').append('
');\n }\n $('.add-to-wishlist-messages')\n .append(`
${data.msg}
`);\n\n setTimeout(() => {\n $('.add-to-wishlist-messages').remove();\n }, 5000);\n}\n\nmodule.exports = {\n addToWishlist() {\n $('body').on('click', '.wishlistTile', function (e) {\n e.preventDefault();\n const icon = $(this).find($('i'));\n const url = $(this).attr('href');\n const pid = $(this).closest('.product').data('pid');\n let optionId = $(this).closest('.product-detail').find('.product-option').attr('data-option-id');\n let optionVal = $(this).closest('.product-detail').find('.options-select option:selected').attr('data-value-id');\n optionId = optionId || null;\n optionVal = optionVal || null;\n if (!url || !pid) {\n return;\n }\n\n $.spinner().start();\n $.ajax({\n url,\n type: 'post',\n dataType: 'json',\n data: {\n pid,\n optionId,\n optionVal,\n },\n success(data) {\n displayMessageAndChangeIcon(data, icon);\n },\n error(err) {\n displayMessageAndChangeIcon(err, icon);\n },\n });\n });\n },\n};\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","/**\n * Update DOM elements with Ajax results\n *\n * @param {number} quantity - quantity\n * @param {string} selector - DOM element to look up in the tile's qty element\n * @return {undefined}\n */\n function updateTile(quantity, selector) {\n $(selector).empty().html(quantity);\n var unitQuantity = $('.unit').html();\n if (quantity && quantity > 0) {\n if(unitQuantity && unitQuantity.trim() == 'kg') {\n var roundedPrice = (Math.round((quantity)*10000)/10000).toString().replace('.', ',');\n $(selector).empty().html(roundedPrice);\n }\n $(selector).closest('.add-to-cart').find('.tile-add-to-cart').removeClass('show');\n $(selector).closest('.add-to-cart').find('.update-quantity').addClass('show');\n } else {\n $(selector).closest('.add-to-cart').find('.tile-add-to-cart').addClass('show');\n $(selector).closest('.add-to-cart').find('.update-quantity').removeClass('show');\n }\n}\n\n/**\n * Keep refinement panes expanded/collapsed after Ajax refresh\n *\n * @param {Object} $results - jQuery DOM element\n * @return {undefined}\n */\nfunction updateQuantities() {\n var items = $('.cart-json').data('cart');\n $('.add-to-cart').find('.tile-add-to-cart').addClass('show');\n $('.add-to-cart').find('.update-quantity').removeClass('show');\n if (items && items.itemsquantities && items.itemsquantities.length > 0) {\n items.itemsquantities.forEach((item) => {\n var variableWeight = $(`.itemquantity-${item.id} .quantity`).closest('.add-to-cart').data('variable-weight');\n if (variableWeight) {\n updateTile(Math.round((item.qty * item.unitValue)*10000)/10000, `.itemquantity-${item.id} .quantity`);\n } else {\n updateTile(item.qty, `.itemquantity-${item.id} .quantity`);\n }\n });\n }\n}\n\n/**\n * Retrieves the relevant pid value\n * @param {jquery} $el - DOM container for a given add to cart button\n * @return {string} - value to be used when adding product to cart\n */\nfunction getPidValue($el) {\n return $($el).closest('.add-to-cart').data('pid');\n}\n\n/**\n * Retrieves url to use when adding a product to the cart\n * @param {jquery} $el - DOM container for a given add to cart button\n * @return {string} - The provided URL to use when adding a product to the cart\n */\nfunction getAddToCartUrl($el) {\n return $($el).closest('.add-to-cart').data('endpoint-add-to-cart');\n}\n\n/**\n * Retrieves url to use when adding a product to the cart\n * @param {jquery} $el - DOM container for a given change qty button\n * @return {string} - The provided URL to use when changing quantity\n */\nfunction getUpdateQuantityUrl($el) {\n return $($el).closest('.add-to-cart').data('endpoint-update-quantity');\n}\n\n/**\n * Parses the html for a modal window\n * @param {string} html - representing the body and footer of the modal window\n *\n * @return {Object} - Object with properties body and footer.\n */\nfunction parseHtml(html) {\n const $html = $('
').append($.parseHTML(html));\n\n const body = $html.find('.choice-of-bonus-product');\n const footer = $html.find('.modal-footer').children();\n\n return { body, footer };\n}\n\n/**\n * Retrieves url to use when adding a product to the cart\n *\n * @param {Object} data - data object used to fill in dynamic portions of the html\n */\nfunction chooseBonusProducts(data) {\n $('.modal-body').spinner().start();\n\n if ($('#chooseBonusProductModal').length !== 0) {\n $('#chooseBonusProductModal').remove();\n }\n let bonusUrl;\n if (data.bonusChoiceRuleBased) {\n bonusUrl = data.showProductsUrlRuleBased;\n } else {\n bonusUrl = data.showProductsUrlListBased;\n }\n\n const htmlString = `${''\n + '
'\n + ''\n + '
`\n + ''\n + '
'\n + '
'\n + ` ${data.labels.selectprods}`\n + ' '\n + '
'\n + '
'\n + '
'\n + '
'\n + '
'\n + '
';\n $('body').append(htmlString);\n $('.modal-body').spinner().start();\n\n $.ajax({\n url: bonusUrl,\n method: 'GET',\n dataType: 'json',\n success(response) {\n const parsedHtml = parseHtml(response.renderedTemplate);\n $('#chooseBonusProductModal .modal-body').empty();\n $('#chooseBonusProductModal .enter-message').text(response.enterDialogMessage);\n $('#chooseBonusProductModal .modal-header .close .sr-only').text(response.closeButtonText);\n $('#chooseBonusProductModal .modal-body').html(parsedHtml.body);\n $('#chooseBonusProductModal .modal-footer').html(parsedHtml.footer);\n $('#chooseBonusProductModal').modal('show');\n $.spinner().stop();\n },\n error() {\n $.spinner().stop();\n }\n });\n}\n\n/**\n * Updates the Mini-Cart quantity value after the customer has pressed the \"Add to Cart\" button\n * @param {string} response - ajax response from clicking the add to cart button\n * @param {jquery} el - DOM container for a given add to cart button\n */\nfunction handlePostCartAdd(response, el) {\n $('.minicart').trigger('count:update', response);\n if (response && response.cart && response.cart.items) {\n const pid = el.closest('.add-to-cart').data('pid');\n const products = response.cart.items.filter((item) => item.id === pid);\n if (products && products.length > 0) {\n var product = products.pop();\n el.closest('.add-to-cart').find('.update-quantity').addClass('show');\n if (product.variableWeight) {\n el.closest('.add-to-cart').find('.update-quantity .quantity').html((Math.round(product.unitData.value *100)/100).toString().replace('.', ','));\n } else {\n el.closest('.add-to-cart').find('.update-quantity .quantity').html('1');\n }\n el.removeClass('show');\n }\n }\n\n const messageType = response.error ? 'alert-danger' : 'alert-success';\n // show add to cart toast\n if (response.newBonusDiscountLineItem\n && Object.keys(response.newBonusDiscountLineItem).length !== 0) {\n chooseBonusProducts(response.newBonusDiscountLineItem);\n } else {\n if ($('.add-to-cart-messages').length === 0) {\n $('body').append('
');\n }\n\n $('.add-to-cart-messages').append(`
${\n response.message\n }
`);\n\n setTimeout(() => {\n $('.add-to-basket-alert').remove();\n }, 5000);\n }\n}\n\n/**\n * Updates the Mini-Cart quantity value after the customer has pressed the \"Add to Cart\" button\n * @param {string} response - ajax response from clicking the quantity change button\n * @param {jquery} el - DOM container for a given quantity change button\n */\nfunction updateQuantity(response, el) {\n if (response && response.items && response.items) {\n let product;\n const pid = el.closest('.add-to-cart').data('pid');\n const products = response.items.filter((item) => item.id === pid);\n if (products && products.length > 0) {\n product = products.pop();\n if (product.variableWeight) {\n var unitQuantity = $('.unit').html();\n if(unitQuantity && unitQuantity.trim() == 'kg') {\n var roundedPrice = (Math.round((product.quantity * product.unitData.value)*1000)/1000).toString().replace('.', ',');\n el.closest('.add-to-cart').find('.update-quantity .quantity').html(roundedPrice);\n } else {\n el.closest('.add-to-cart').find('.update-quantity .quantity').html(roundedPrice);\n }\n } else {\n el.closest('.add-to-cart').find('.update-quantity .quantity').html((Math.round(product.quantity*100)/100).toString().replace('.', ','));\n }\n }\n }\n}\n\n/**\n * Makes a call to the server to report the event of adding an item to the cart\n *\n * @param {string | boolean} url - a string representing the end point to hit so that the event can be recorded, or false\n */\nfunction miniCartReportingUrl(url) {\n if (url) {\n $.ajax({\n url,\n method: 'GET',\n success() {\n // reporting urls hit on the server\n },\n error() {\n // no reporting urls hit on the server\n }\n });\n }\n}\n\n/**\n * Makes a CSRF-token research in the twolineheader element to fill the product-notes-form\n * Deletes the previous csrf_token if already exists\n * @param {Element} div - principal div in notes form\n */\nfunction fillCSRFToken(modalForm) {\n var csrfTokenName = $('#customerConnectTk input[type=\"hidden\"]').attr('name');\n var csrfTokenValue = $('#customerConnectTk input[type=\"hidden\"]').val();\n\n if (csrfTokenName && csrfTokenValue) {\n // Search and deletes previous input (to ignore possible cached elements)\n modalForm.find('input[name=\"' + csrfTokenName + '\"]').remove();\n // Creates new input element\n var csrfInput = $('', {\n type: 'hidden',\n name: csrfTokenName,\n value: csrfTokenValue\n });\n // Append new input element\n modalForm.find('.modal-body').append(csrfInput);\n }\n}\n\n// /**\n// * Actulization of shadow in tiles\n// * @param {Element} div - product-tile div\n// */\n// function applyPromoStyles() {\n// $('.product-tile').each(function() {\n// var $tile = $(this);\n\n// // Verifica si la clase .strike-through existe en la tile\n// var hasStrikeThrough = $tile.find('.strike-through').length > 0;\n\n// // Verifica si la clase .tile-promotions tiene hijos\n// var hasPromotionChildren = $tile.find('.tile-promotions').children().length > 0;\n\n// // Verifica si la clase .discount-plp existe en la tile\n// var hasDiscountPlp = $tile.find('.discount-plp').length > 0;\n\n// // Si se cumple alguna de las condiciones, añade la clase product-tile-shadow\n// if (hasStrikeThrough || hasPromotionChildren || hasDiscountPlp) {\n// $tile.removeClass('product-tile-shadow-green');\n// $tile.addClass('product-tile-shadow-red');\n// } else {\n// $tile.removeClass('product-tile-shadow-red');\n// $tile.addClass('product-tile-shadow-green');\n// }\n// });\n// }\n\n// // Evento de escucha a la carga para verificar si hay que aplicar styles de promoción\n// $(document).ready(function () {\n// // Nodos a observar\n// const targetNodes = [\n// $('.experience-einstein-einsteinCarouselCategoryMM')[0], // Home\n// $('.experience-einstein')[0] // PLP, PDP, WISHLIST, etc.\n// ];\n\n// const observer = new MutationObserver(function(mutationsList, observer) {\n// for (let mutation of mutationsList) {\n// if (mutation.type === 'childList' && mutation.addedNodes.length > 0) {\n// applyPromoStyles();\n// break;\n// }\n// }\n// });\n\n// // Inicio de la observación en cada nodo\n// targetNodes.forEach(function(targetNode) {\n// if (targetNode) {\n// observer.observe(targetNode, { childList: true, subtree: true });\n// }\n// });\n// });\n\nmodule.exports = {\n addToCart() {\n $(document).on('click', 'button.tile-add-to-cart', function (event) {\n event.stopPropagation();\n event.preventDefault();\n const el = $(this);\n\n $('body').trigger('product:beforeAddToCart', this);\n\n const pid = getPidValue($(this));\n\n let $productContainer = $(this).closest('.product-detail');\n if (!$productContainer.length) {\n $productContainer = $(this).closest('.quick-view-dialog').find('.product-detail');\n }\n\n const addToCartUrl = getAddToCartUrl(el);\n\n const form = {\n pid,\n quantity: 0\n };\n\n $(this).trigger('updateAddToCartFormData', form);\n if (addToCartUrl) {\n $.ajax({\n url: addToCartUrl,\n method: 'POST',\n data: form,\n success(data) {\n handlePostCartAdd(data, el);\n $('body').trigger('product:afterAddToCart', data);\n $.spinner().stop();\n miniCartReportingUrl(data.reportingURL);\n },\n error() {\n $.spinner().stop();\n }\n });\n }\n });\n },\n updateQuantityCart() {\n $(document).on('click', 'button.tile-update-quantity', function (event) {\n event.stopPropagation();\n event.preventDefault();\n const el = $(this);\n\n $('body').trigger('product:beforeAddToCart', this);\n\n const pid = getPidValue($(this));\n const updateQuantityUrl = getUpdateQuantityUrl($(this));\n const decrease = $(this).data('decrease');\n\n let $productContainer = $(this).closest('.product-detail');\n if (!$productContainer.length) {\n $productContainer = $(this).closest('.quick-view-dialog').find('.product-detail');\n }\n\n const form = {\n pid,\n decrease,\n quantity: 1\n };\n\n $(this).trigger('updateAddToCartFormData', form);\n if (updateQuantityUrl) {\n $.ajax({\n url: updateQuantityUrl,\n method: 'GET',\n data: form,\n success(data) {\n $('.minicart').trigger('count:update', data);\n $('body').trigger('product:afterAddToCart', data);\n $('.minicart .minicart-quantity .text').text(data.quantityTotal);\n var prodsQuantity = 0;\n if (data && data.basket && data.basket.items) {\n const id = el.closest('.add-to-cart').data('pid');\n const products = data.basket.items.filter((item) => item.id === id);\n if (products.length === 0) {\n // Veficar que esta en detailsPDP para ver si va con el sticky, para modificar los dos\n const isInDetailsPDP = el.closest('.detailsPDP').length > 0;\n\n if (isInDetailsPDP) {\n // Modificamos los dos elementos .add-to-cart dentro de .detailsPDP que serían el propio de la PDP y el sticky\n $('.detailsPDP .add-to-cart').each(function () {\n const buttonContainer = $(this);\n\n buttonContainer.find('.update-quantity').removeClass('show');\n buttonContainer.find('.tile-add-to-cart').addClass('show');\n });\n } else {\n // Modifica el boton .add-to-cart donde se hizo clic\n el.closest('.add-to-cart').find('.update-quantity').removeClass('show');\n el.closest('.add-to-cart').find('.tile-add-to-cart').addClass('show');\n }\n }\n\n const items = data.basket.items;\n\n for (var i = 0; i < items.length; i++) {\n if (items[i].unitData && items[i].unitData.unit === 'kg') {\n prodsQuantity++;\n } else {\n prodsQuantity += items[i].quantity;\n }\n }\n $('.minicart .minicart-quantity .text').text(prodsQuantity.toString().replace('.', ','));\n } else if (data && data.items) {\n\n const addToCartButtons = $('.add-to-cart');\n\n // Modificamos los dos elementos .add-to-cart (normal y sticky) presentes en la PDP\n addToCartButtons.each(function () {\n const buttonContainer = $(this);\n\n updateQuantity(data, buttonContainer);\n });\n\n\n const items = data.items;\n\n for (var i = 0; i < items.length; i++) {\n if (items[i].unitData && items[i].unitData.unit === 'kg') {\n prodsQuantity++;\n } else {\n prodsQuantity += items[i].quantity;\n }\n }\n $('.minicart .minicart-quantity .text').text(prodsQuantity.toString().replace('.', ','));\n }\n $.spinner().stop();\n miniCartReportingUrl(data.reportingURL);\n },\n error() {\n $.spinner().stop();\n }\n });\n }\n });\n },\n updateMinicart() {\n $('body').on('cart:update', () => {\n updateQuantities();\n });\n },\n notesTokenModalEvent() {\n $('.modal.center-modal-product-notes').on('shown.bs.modal', function () {\n fillCSRFToken($(this));\n })\n },\n updateQuantities: updateQuantities,\n};\n","'use strict';\n\nvar processInclude = require('base/util');\n\n$(document).ready(function () {\n processInclude(require('./search/search'));\n // processInclude(require('base/product/quickView'));\n processInclude(require('sunnie_foods/product/wishlistHeart'));\n processInclude(require('./product/tile'));\n});\n","'use strict';\n\nvar tileHelper = require('../product/tile');\n\n/**\n * Update DOM elements with Ajax results\n *\n * @param {Object} $results - jQuery DOM element\n * @param {string} selector - DOM element to look up in the $results\n * @return {undefined}\n */\nfunction updateDom($results, selector) {\n var $updates = $results.find(selector);\n $(selector).empty().html($updates.html());\n}\n\n/**\n * Keep refinement panes expanded/collapsed after Ajax refresh\n *\n * @param {Object} $results - jQuery DOM element\n * @return {undefined}\n */\nfunction handleRefinements($results) {\n $('.refinement.active').each(function () {\n $(this).removeClass('active');\n var activeDiv = $results.find('.' + $(this)[0].className.replace(/ /g, '.'));\n activeDiv.addClass('active');\n activeDiv.find('button.title').attr('aria-expanded', 'true');\n });\n\n updateDom($results, '.refinements');\n}\n\n/**\n * Parse Ajax results and updated select DOM elements\n *\n * @param {string} response - Ajax response HTML code\n * @return {undefined}\n */\nfunction parseResults(response) {\n var $results = $(response);\n var specialHandlers = {\n '.refinements': handleRefinements\n };\n\n // Update DOM elements that do not require special handling\n [\n '.grid-header',\n '.header-bar',\n '.header.page-title',\n '.product-grid',\n '.show-more',\n '.filter-bar'\n ].forEach(function (selector) {\n updateDom($results, selector);\n });\n\n Object.keys(specialHandlers).forEach(function (selector) {\n specialHandlers[selector]($results);\n });\n}\n\n/**\n * This function retrieves another page of content to display in the content search grid\n * @param {JQuery} $element - the jquery element that has the click event attached\n * @param {JQuery} $target - the jquery element that will receive the response\n * @return {undefined}\n */\nfunction getContent($element, $target) {\n var showMoreUrl = $element.data('url');\n $.spinner().start();\n $.ajax({\n url: showMoreUrl,\n method: 'GET',\n success: function (response) {\n $target.append(response);\n $.spinner().stop();\n },\n error: function () {\n $.spinner().stop();\n }\n });\n}\n\n/**\n * Update sort option URLs from Ajax response\n *\n * @param {string} response - Ajax response HTML code\n * @return {undefined}\n */\nfunction updateSortOptions(response) {\n var $tempDom = $('
').append($(response));\n var sortOptions = $tempDom.find('.grid-footer').data('sort-options').options;\n sortOptions.forEach(function (option) {\n $('option.' + option.id).val(option.url);\n });\n}\n\n$(document).ready(function (){\n $(document).on('click', '#see-more', function (){\n var noneClassCounter = 0;\n $(\".values.content li\").each(function(index) {\n if ($(this).hasClass(\"d-none\") && noneClassCounter < 10) {\n $(this).removeClass(\"d-none\");\n noneClassCounter = noneClassCounter + 1;\n }\n });\n if ($(\".values.content li.d-none\").length === 0) {\n $(\"#see-more\").addClass(\"d-none\");\n } \n });\n})\n\nmodule.exports = {\n filter: function () {\n // Display refinements bar when Menu icon clicked\n $('.container').on('click', 'button.filter-results', function () {\n $('.refinement-bar, .modal-background').show();\n $('.refinement-bar').siblings().attr('aria-hidden', true);\n $('.refinement-bar').closest('.row').siblings().attr('aria-hidden', true);\n $('.refinement-bar').closest('.tab-pane.active').siblings().attr('aria-hidden', true);\n $('.refinement-bar').closest('.container.search-results').siblings().attr('aria-hidden', true);\n $('.refinement-bar .close').focus();\n });\n },\n\n closeRefinements: function () {\n // Refinements close button\n $('.container').on('click', '.refinement-bar button.close, .modal-background', function () {\n $('.refinement-bar, .modal-background').hide();\n $('.refinement-bar').siblings().attr('aria-hidden', false);\n $('.refinement-bar').closest('.row').siblings().attr('aria-hidden', false);\n $('.refinement-bar').closest('.tab-pane.active').siblings().attr('aria-hidden', false);\n $('.refinement-bar').closest('.container.search-results').siblings().attr('aria-hidden', false);\n $('.btn.filter-results').focus();\n });\n },\n\n resize: function () {\n // Close refinement bar and hide modal background if user resizes browser\n $(window).resize(function () {\n $('.refinement-bar, .modal-background').hide();\n $('.refinement-bar').siblings().attr('aria-hidden', false);\n $('.refinement-bar').closest('.row').siblings().attr('aria-hidden', false);\n $('.refinement-bar').closest('.tab-pane.active').siblings().attr('aria-hidden', false);\n $('.refinement-bar').closest('.container.search-results').siblings().attr('aria-hidden', false);\n });\n },\n\n sort: function () {\n // Handle sort order menu selection\n $('.container').on('change', '[name=sort-order]', function (e) {\n e.preventDefault();\n\n $.spinner().start();\n $(this).trigger('search:sort', this.value);\n $.ajax({\n url: this.value,\n data: { selectedUrl: this.value },\n method: 'GET',\n success: function (response) {\n $('.product-grid').empty().html(response);\n $.spinner().stop();\n },\n error: function () {\n $.spinner().stop();\n }\n });\n });\n },\n\n showMore: function () {\n // Show more products\n $('.container').on('click', '.show-more button', function (e) {\n e.stopPropagation();\n var showMoreUrl = $(this).data('url');\n e.preventDefault();\n\n $.spinner().start();\n $(this).trigger('search:showMore', e);\n $.ajax({\n url: showMoreUrl,\n data: { selectedUrl: showMoreUrl },\n method: 'GET',\n success: function (response) {\n $('.grid-footer').replaceWith(response);\n updateSortOptions(response);\n $.spinner().stop();\n tileHelper.updateQuantities();\n },\n error: function () {\n $.spinner().stop();\n }\n });\n });\n },\n\n applyFilter: function () {\n // Handle refinement value selection and reset click\n $('.container').on(\n 'click',\n '.refinements li button, .refinement-bar button.reset, .filter-value button, .swatch-filter button',\n function (e) {\n e.preventDefault();\n e.stopPropagation();\n\n $.spinner().start();\n $(this).trigger('search:filter', e);\n $.ajax({\n url: $(this).data('href'),\n data: {\n page: $('.grid-footer').data('page-number'),\n selectedUrl: $(this).data('href')\n },\n method: 'GET',\n success: function (response) {\n parseResults(response);\n $.spinner().stop();\n },\n error: function () {\n $.spinner().stop();\n }\n });\n });\n },\n\n showContentTab: function () {\n // Display content results from the search\n $('.container').on('click', '.content-search', function () {\n if ($('#content-search-results').html() === '') {\n getContent($(this), $('#content-search-results'));\n }\n });\n\n // Display the next page of content results from the search\n $('.container').on('click', '.show-more-content button', function () {\n getContent($(this), $('#content-search-results'));\n $('.show-more-content').remove();\n });\n },\n};\n"],"sourceRoot":""}