{"version":3,"file":"default/js/login.js","mappings":";;;;;;;;;;AAAa;;AAEb;AACA;AACA,WAAW,SAAS;AACpB,aAAa;AACb;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,sBAAsB;AACtB;AACA;AACA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA,gFAAgF,qCAAqC;AACrH;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;;;;;;;;;;AC/CA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA,oCAAoC,iBAAiB;AACrD;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA,KAAK;;AAEL;AACA;AACA,gCAAgC,iBAAiB;AACjD;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,SAAS;;AAET;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA,oBAAoB,gCAAgC;AACpD;AACA;AACA,UAAU;AACV;AACA;AACA;;AAEA;AACA;;AAEA,4BAA4B;AAC5B,yBAAyB;AACzB,uBAAuB;AACvB,2BAA2B;AAC3B,wBAAwB;AACxB,uBAAuB;AACvB,6BAA6B;AAC7B,wBAAwB;AACxB,wBAAwB;AACxB,uBAAuB;AACvB,6BAA6B;;;;;;;;;;;;AClZhB;;AAEb,qBAAqB,mBAAO,CAAC,uHAA8B;AAC3D,oBAAoB,mBAAO,EAAE,2GAAwB;AACrD,eAAe,mBAAO,EAAE,2FAAgB;AACxC,UAAU,mBAAO,CAAC,2EAAQ;AAC1B,uBAAuB,mBAAO,CAAC,6GAAyB;;AAExD;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA,KAAK;;AAEL;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA,UAAU,QAAQ;AAClB,UAAU,SAAS;AACnB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B;AAC1B;AACA;;AAEA;AACA;AACA,qBAAqB;AACrB;AACA;AACA;AACA,0BAA0B;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB;AACjB;AACA;;AAEA;AACA;AACA,cAAc;AACd;AACA;AACA,SAAS;AACT,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,sBAAsB;AACtB;AACA;AACA;AACA,iBAAiB;AACjB;AACA;AACA;AACA,sBAAsB;AACtB;AACA;AACA;AACA;AACA,aAAa;AACb;;AAEA;AACA;AACA,SAAS;AACT,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB;AACtB;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB;AACjB;AACA;AACA;AACA,aAAa;AACb;AACA,SAAS;AACT,KAAK;;AAEL;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;;AAEL;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA,sBAAsB;AACtB;AACA;AACA;AACA,iBAAiB;AACjB;AACA;AACA;AACA,sBAAsB;AACtB;AACA;AACA;AACA;AACA,aAAa;AACb;;AAEA;AACA;AACA,SAAS;AACT,KAAK;AACL;;;;;;;;;;;;AC7Qa;;AAEb;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA,iBAAiB;AACjB;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;AACA;AACA;AACA;;;;;;;;;;;;ACtCa;;AAEb;AACA;AACA;;AAEA;AACA;AACA,YAAY,QAAQ;AACpB,aAAa,SAAS;AACtB,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,UAAU,SAAS;AACnB,YAAY;AACZ;AACA;AACA;AACA;;AAEA;AACA;AACA,UAAU,UAAU;AACpB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyB;AACzB;AACA;AACA;AACA,qBAAqB;AACrB;;AAEA;AACA;AACA;;AAEA;AACA,SAAS;;AAET;AACA;;AAEA;AACA;;AAEA;AACA;AACA,UAAU,UAAU;AACpB,YAAY,iBAAiB;AAC7B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;ACxGa;;AAEb;AACA;AACA,UAAU,QAAQ;AAClB,UAAU,QAAQ;AAClB,YAAY;AACZ;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA,wEAAwE;AACxE;AACA;AACA,kBAAkB;AAClB;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA,kBAAkB;AAClB;AACA,oDAAoD;AACpD;AACA;AACA,kBAAkB;AAClB;AACA;;AAEA;AACA;AACA;AACA,SAAS;;AAET;;AAEA;AACA;AACA;AACA;AACA;;;;;;;;;;;;ACxDa;;AAEb;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;;;;;;;UCZA;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;;AAExC;AACA,mBAAmB,mBAAO,CAAC,0FAAe;AAC1C,CAAC","sources":["webpack://sfra-startup-kit/./cartridges/app_ahumada/cartridge/client/default/js/components/formValidation.js","webpack://sfra-startup-kit/./cartridges/app_ahumada/cartridge/client/default/js/gtm.js","webpack://sfra-startup-kit/./cartridges/app_ahumada/cartridge/client/default/js/login/login.js","webpack://sfra-startup-kit/./cartridges/app_ahumada/cartridge/client/default/js/utils/masks.js","webpack://sfra-startup-kit/./cartridges/app_ahumada/cartridge/client/default/js/utils/recaptchaUtils.js","webpack://sfra-startup-kit/./cartridges/app_ahumada/cartridge/client/default/js/utils/utilsServices.js","webpack://sfra-startup-kit/./cartridges/app_storefront_base/cartridge/client/default/js/util.js","webpack://sfra-startup-kit/webpack/bootstrap","webpack://sfra-startup-kit/./cartridges/app_ahumada/cartridge/client/default/js/login.js"],"sourcesContent":["\"use strict\";\n\n/**\n * Remove all validation. Should be called every time before revalidating form\n * @param {element} form - Form to be cleared\n * @returns {void}\n */\nfunction clearFormErrors(form) {\n $(form).find(\".form-control.is-invalid\").removeClass(\"is-invalid\");\n}\n\nmodule.exports = function (formElement, payload) {\n // clear form validation first\n clearFormErrors(formElement);\n $(\".alert\", formElement).remove();\n\n if (typeof payload === \"object\" && payload.fields) {\n Object.keys(payload.fields).forEach(function (key) {\n if (payload.fields[key]) {\n var feedbackElement = $(formElement).find(\"[name=\\\"\" + key + \"\\\"]\")\n .parent()\n .children(\".invalid-feedback\");\n\n if (feedbackElement.length > 0) {\n if (Array.isArray(payload[key])) {\n feedbackElement.html(payload.fields[key].join(\"
\"));\n } else {\n feedbackElement.html(payload.fields[key]);\n }\n feedbackElement.siblings(\".form-control\").addClass(\"is-invalid\");\n }\n }\n });\n\n // Scroll to the first invalid field\n if ($(formElement).find(\".form-control.is-invalid\").length) {\n $(formElement).find(\".form-control.is-invalid\")[0].scrollIntoView({ behavior: \"smooth\", block: \"center\" });\n }\n }\n if (payload && payload.error) {\n var form = $(formElement).prop(\"tagName\") === \"FORM\"\n ? $(formElement)\n : $(formElement).parents(\"form\");\n\n form.prepend(\"
\"\n + payload.error.join(\"
\") + \"
\");\n }\n};\n","let currencyCode = $(\".gtm-data\").attr(\"data-currency\");\n\n// triggers page_view event\nfunction pageViewEvent() {\n const $gtmData = $(\".gtm-data\");\n let userType = $gtmData.attr(\"data-customer\") === \"true\" ? \"Registered\" : \"Guest\";\n let language = $gtmData.attr(\"data-language\").toUpperCase();\n let pageTitle = document.title;\n let pageLocation = window.location.href;\n let userID = $gtmData.attr(\"data-customer-id\") ? $gtmData.attr(\"data-customer-id\") : \"\";\n window.dataLayer &&\n window.dataLayer.push({\n \"event\": \"page_view\",\n \"user_id\": userID,\n \"user_type\": userType,\n \"site_language\": language,\n \"page_title\": pageTitle,\n \"page_location\": pageLocation\n });\n}\n\n// triggers select_item event\nfunction selectItem(element) {\n const $productTile = $(element);\n let productID = $productTile.attr(\"data-pid\");\n let productBrand = $productTile.find(\".product-tile-brand .link\").text().trim();\n let productName = $productTile.find(\".pdp-link .link\").text().trim();\n let productPrice = Number($productTile.find(\".price .value\").text().trim().substring(1).replace(\".\", \"\"));\n let productCategoryList = $productTile.attr(\"data-categories\").split(\",\");\n\n let item = {\n \"item_name\": productName,\n \"item_id\": productID,\n \"price\": productPrice,\n \"item_brand\": productBrand,\n \"quantity\": 1,\n \"index\": 0\n };\n\n let newItem = appendCategories(item, productCategoryList);\n\n window.dataLayer &&\n window.dataLayer.push({\n \"event\": \"select_item\",\n \"ecommerce\": {\n \"currency\": currencyCode,\n \"value\": productPrice,\n \"items\": [newItem]\n }\n });\n}\n\n// triggers view_item event\nfunction viewItem() {\n const $product = $(\".product-detail\");\n const $productDetails = $product.find(\".product-details-section\");\n let productID = $product.attr(\"data-pid\");\n let productBrand = $productDetails.find(\".brand\").text().trim() || $productDetails.find(\".manufacturer-name\").text().trim();\n let productName = $productDetails.find(\".product-name\").text().trim();\n let productPrice = Number($productDetails.find(\".sales .value\").text().trim().substring(1).replace(\".\", \"\"));\n let productCategoryList = $productDetails.find(\".gtm-categories\").text().trim().split(\",\");\n let item = {\n \"item_name\": productName,\n \"item_id\": productID,\n \"price\": productPrice,\n \"item_brand\": productBrand,\n \"quantity\": 1,\n \"index\": 0\n };\n\n let newItem = appendCategories(item, productCategoryList);\n\n window.dataLayer &&\n window.dataLayer.push({\n \"event\": \"view_item\",\n \"ecommerce\": {\n \"currency\": currencyCode,\n \"value\": productPrice,\n \"items\": [newItem]\n }\n });\n}\n\n// triggers view_item_list event\nfunction viewItemList(element, startValue) {\n const $productTile = startValue ? $(element).find(\".product-tile:gt(\" + startValue + \")\") : $(element).find(\".product-tile\");\n const batchSize = 20;\n var objects = [];\n\n $productTile.each(function (index) {\n let productID = $(this).attr(\"data-pid\");\n let productBrand = $(this).find(\".product-tile-brand .link\").text().trim();\n let productName = $(this).find(\".pdp-link .link\").text().trim();\n let productPrice = Number($(this).find(\".price .value\").first().text().trim().substring(1).replace(\".\", \"\"));\n\n const item = {\n \"item_name\": productName,\n \"item_id\": productID,\n \"price\": productPrice,\n \"brand\": productBrand,\n \"quantity\": 1,\n \"index\": index\n };\n\n let productCategoryList = $(this).attr(\"data-categories\").split(\",\");\n let newItem = appendCategories(item, productCategoryList);\n\n objects.push(newItem);\n\n if (objects.length === batchSize) {\n window.dataLayer.push({ ecommerce: null });\n window.dataLayer.push({\n \"event\": \"view_item_list\",\n \"ecommerce\": {\n \"currency\": currencyCode,\n \"items\": objects\n }\n });\n objects = [];\n }\n });\n\n if (objects.length > 0) {\n window.dataLayer &&\n window.dataLayer.push({ ecommerce: null });\n window.dataLayer.push({\n \"event\": \"view_item_list\",\n \"ecommerce\": {\n \"currency\": currencyCode,\n \"items\": objects\n }\n });\n }\n}\n\n// triggers add_to_cart event\nfunction addToCart(element, productType, quantity, isMinicart) {\n const $product = $(element);\n const $productDetails = $product.find(\".product-details-section\");\n let productID, productBrand, productName, productPrice, productQuantity, productCategoryList, totalValue;\n switch (productType) {\n case \"ahumadaFamilyProductPromotion\":\n productID = $product.data(\"data-pid\");\n productBrand = $product.data(\"product-brand\");\n productName = $product.data(\"product-name\");\n productPrice = Number($product.data(\"product-price\"));\n productQuantity = 1;\n productCategoryList = $product.data(\"categories\").split(\",\");\n totalValue = productPrice;\n break;\n case \"tile\":\n productID = $product.attr(\"data-pid\");\n productBrand = $product.find(\".product-tile-brand .link\").text().trim();\n productName = $product.find(\".pdp-link .link\").text().trim();\n productPrice = Number($product.find(\".price .value\").text().trim().substring(1).replace(\".\", \"\"));\n productQuantity = 1;\n productCategoryList = $product.attr(\"data-categories\").split(\",\");\n totalValue = productPrice;\n break;\n case \"detail\":\n productID = $product.attr(\"data-pid\");\n productBrand = $productDetails.find(\".brand\").text().trim() || $productDetails.find(\".manufacturer-name\").text().trim();\n productName = $productDetails.find(\".product-name\").text().trim();\n productPrice = Number($productDetails.find(\".sales .value\").text().trim().substring(1).replace(\".\", \"\"));\n productQuantity = Number($productDetails.find(\".quantity-select\").val());\n productCategoryList = $productDetails.find(\".gtm-categories\").text().trim().split(\",\");\n totalValue = productPrice * productQuantity;\n break;\n case \"cart\":\n if (isMinicart) {\n productID = $product.attr(\"data-pid\");\n productBrand = $product.attr(\"data-brand\");\n productName = $product.find(\".line-item-name span\").text().trim();\n productPrice = Number($product.find(\".sales .value\").text().trim().substring(1).replace(\".\", \"\"));\n productCategoryList = $product.attr(\"data-categories\").split(\",\");\n } else {\n productID = $product.attr(\"data-pid\");\n productBrand = $product.attr(\"data-brand\");\n productName = $product.find(\".line-item-product-name\").text().trim();\n productPrice = Number($product.find(\".sales .value\").text().trim().substring(1).replace(\".\", \"\"));\n productCategoryList = $product.attr(\"data-categories\").split(\",\");\n }\n productQuantity = Number(quantity);\n totalValue = productPrice * productQuantity;\n break;\n default:\n break;\n }\n let item = {\n \"item_name\": productName,\n \"item_id\": productID,\n \"price\": productPrice,\n \"item_brand\": productBrand,\n \"quantity\": productQuantity,\n \"index\": 0\n };\n\n let newItem = appendCategories(item, productCategoryList);\n\n window.dataLayer &&\n window.dataLayer.push({\n \"event\": \"add_to_cart\",\n \"ecommerce\": {\n \"currency\": currencyCode,\n \"value\": totalValue,\n \"items\": [newItem]\n }\n });\n}\n\n// triggers add_to_cart event\nfunction removeFromCart(element, quantity, isMinicart) {\n const $product = $(element);\n let productID, productBrand, productName, productPrice, productQuantity, productCategoryList, totalValue;\n if (isMinicart) {\n productID = $product.attr(\"data-pid\");\n productBrand = $product.attr(\"data-brand\");\n productName = $product.find(\".line-item-name span\").text().trim();\n productPrice = Number($product.find(\".sales .value\").text().trim().substring(1).replace(\".\", \"\"));\n productCategoryList = $product.attr(\"data-categories\").split(\",\");\n } else {\n productID = $product.attr(\"data-pid\");\n productBrand = $product.attr(\"data-brand\");\n productName = $product.find(\".line-item-product-name\").text().trim();\n productPrice = Number($product.find(\".sales .value\").text().trim().substring(1).replace(\".\", \"\"));\n productCategoryList = $product.attr(\"data-categories\").split(\",\");\n }\n productQuantity = Number(quantity);\n totalValue = productPrice * productQuantity;\n\n let item = {\n \"item_name\": productName,\n \"item_id\": productID,\n \"price\": productPrice,\n \"item_brand\": productBrand,\n \"quantity\": productQuantity,\n \"index\": 0\n };\n\n let newItem = appendCategories(item, productCategoryList);\n\n window.dataLayer &&\n window.dataLayer.push({\n \"event\": \"remove_from_cart\",\n \"ecommerce\": {\n \"currency\": currencyCode,\n \"value\": totalValue,\n \"items\": [newItem]\n }\n });\n}\n\n// triggers view_cart event\nfunction viewCart() {\n const $products = $(\".product-info\");\n const basketValue = Number($(\".grand-total\").text().trim().substring(1).replace(\".\", \"\"));\n var objects = [];\n\n if ($products.length) {\n $products.each(function (index) {\n let productID = $(this).attr(\"data-pid\");\n let productBrand = $(this).attr(\"data-brand\");\n let productName = $(this).find(\".line-item-product-name\").text().trim();\n let productPrice = Number($(this).find(\".sales .value\").text().trim().substring(1).replace(\".\", \"\"));\n let productCategoryList = $(this).attr(\"data-categories\").split(\",\");\n let productQuantity = Number($(this).find(\".quantity.custom-select\").val());\n\n const item = {\n \"item_name\": productName,\n \"item_id\": productID,\n \"price\": productPrice,\n \"brand\": productBrand,\n \"quantity\": productQuantity,\n \"index\": index\n };\n\n let newItem = appendCategories(item, productCategoryList);\n objects.push(newItem);\n });\n\n window.dataLayer &&\n window.dataLayer.push({\n \"event\": \"view_cart\",\n \"ecommerce\": {\n \"currency\": currencyCode,\n \"value\": basketValue,\n \"items\": objects\n }\n });\n }\n}\n\n// Used to trigger begin_checkout, add_shipping_info and add_payment_info event\nfunction checkoutEvents(label) {\n const $products = $(\".product-summary-block .product-line-item\");\n const basketValue = Number($(\".grand-total-sum\").first().text().trim().substring(1).replace(\".\", \"\"));\n var objects = [];\n\n $products.each(function (index) {\n let productID = $(this).attr(\"data-pid\");\n let productBrand = $(this).attr(\"data-brand\");\n let productName = $(this).find(\".line-item-name span\").text().trim();\n let productPrice = Number($(this).find(\".sales .value\").text().trim().substring(1).replace(\".\", \"\") || $(this).find(\".price .value\").text().trim().substring(1).replace(\".\", \"\"));\n let productCategoryList = $(this).attr(\"data-categories\").split(\",\");\n let productQuantity = Number($(this).find(\".qty-card-quantity-count\").text().trim());\n\n const item = {\n \"item_name\": productName,\n \"item_id\": productID,\n \"price\": productPrice,\n \"brand\": productBrand,\n \"quantity\": productQuantity,\n \"index\": index\n };\n\n let newItem = appendCategories(item, productCategoryList);\n objects.push(newItem);\n });\n\n var ecommerceObject = {\n \"currency\": currencyCode,\n \"value\": basketValue,\n \"items\": objects\n };\n\n switch (label) {\n case \"add_shipping_info\":\n ecommerceObject[\"shipping_tier\"] = $(\".shipping-method-block .delivery-type-container.active\").first().find(\".custom-control-label\").text().trim();\n break;\n case \"add_payment_info\":\n ecommerceObject[\"payment_type\"] = $(\".ahumada-custom-radio.selected\").first().closest(\".payment-methos-accordion-header\").attr(\"id\");\n break;\n case \"purchase\":\n ecommerceObject[\"transaction_id\"] = $(\".summary-details.order-number\").text().trim();\n ecommerceObject[\"shipping\"] = $(\".shipping-method-title\").text().trim();\n ecommerceObject[\"payment\"] = $(\".credit-card-type span\").text().trim();\n break;\n default:\n break;\n }\n\n window.dataLayer &&\n window.dataLayer.push({\n \"event\": label,\n \"ecommerce\": ecommerceObject\n });\n}\n\n// triggers sign_up event\nfunction gtmSignUp() {\n window.dataLayer &&\n window.dataLayer.push({\n \"event\": \"sign_up\",\n \"method\": \"Email\"\n });\n}\n\n// triggers sign_up event\nfunction gtmLogin() {\n window.dataLayer &&\n window.dataLayer.push({\n \"event\": \"login\",\n \"method\": \"Email\"\n });\n}\n\n// triggers search event\nfunction gtmSearch() {\n const resultsCount = $(\".search-result-count\").attr(\"data-results-count\");\n const searchQuery = $(\".search-result-for\").attr(\"data-search-query\");\n\n window.dataLayer &&\n window.dataLayer.push({\n \"event\": \"search\",\n \"search_term\": searchQuery,\n \"search_results\": Number(resultsCount)\n });\n}\n\n// adds the categories to the item object\nfunction appendCategories(item, productCategoryList) {\n for (let j = 0; j < productCategoryList.length; j++) {\n if (j === 0) {\n item.item_category = productCategoryList[j];\n } else {\n item[\"item_category\" + (j + 1)] = productCategoryList[j].replace(/'/g, \"\");\n }\n }\n\n return item;\n}\n\nmodule.exports.pageViewEvent = pageViewEvent;\nmodule.exports.selectItem = selectItem;\nmodule.exports.viewItem = viewItem;\nmodule.exports.viewItemList = viewItemList;\nmodule.exports.addToCart = addToCart;\nmodule.exports.viewCart = viewCart;\nmodule.exports.removeFromCart = removeFromCart;\nmodule.exports.gtmSearch = gtmSearch;\nmodule.exports.gtmSignUp = gtmSignUp;\nmodule.exports.gtmLogin = gtmLogin;\nmodule.exports.checkoutEvents = checkoutEvents;\n","\"use strict\";\n\nvar formValidation = require(\"../components/formValidation\");\nvar utilsServices = require (\"../utils/utilsServices\");\nvar utilMask = require (\"../utils/masks\");\nvar gtm = require(\"../gtm\");\nconst recaptchaUtils = require(\"../utils/recaptchaUtils\");\n\nconst showErrorEmailRegistered = () => {\n const $notification = $(\".notification-alert\");\n const messageHasSameEmail = $(\"#hasCustomerWithSameEmail\").attr(\"message\");\n\n utilsServices.createErrorNotification(messageHasSameEmail, $notification);\n};\n\nconst listenEventsForm = () => {\n $(\".form-rut-field\").add(\"#sociallogin-form-rut\").on(\"keydown\", (e) => {\n utilMask.maskRUT(e.target);\n });\n\n $(\"#registration-form-birthdate\").on(\"keydown\", (e) => {\n utilMask.maskBirthdate(e.target);\n });\n\n $(\"#registration-form-phone\").add(\"#sociallogin-form-phone\").on(\"keydown\", (e) => {\n utilMask.maskPhone(e.target);\n });\n};\n\n/**\n* Handles the login form button\n* @param {Object} button - The button element\n* @param {boolean} disabled - Whether the button should be disabled or not\n*/\nconst handleLoginFormButton = (button, disabled) => {\n button.prop(\"disabled\", disabled);\n};\n\nmodule.exports = {\n initialize: function () {\n const showModal = $(\"#isShowRegisterCustomerModal\").val();\n const hasCustomerWithSameEmail = $(\"#hasCustomerWithSameEmail\").val();\n\n if (showModal === \"true\") {\n $(\"#linkOpenRegisterCustomerModal\").trigger(\"click\");\n }\n\n if (hasCustomerWithSameEmail === \"true\") {\n showErrorEmailRegistered();\n }\n\n utilMask.maskRUT($(\".form-rut-field\"));\n\n listenEventsForm();\n },\n\n login: function () {\n $(\"form.login\").submit(function (e) {\n var form = $(this);\n e.preventDefault();\n var url = form.attr(\"action\");\n const loginButton = form.find(\".btn-submit-login\");\n const recaptchaSettings = recaptchaUtils.getGRecaptchaConfigurationObject();\n const isRecaptchaEnabled = recaptchaSettings.isEnabled && $(\".grecaptcha-container\").children().length > 0;\n form.spinner().start();\n $(\"form.login\").trigger(\"login:submit\", e);\n handleLoginFormButton(loginButton, true);\n\n const callback = function () {\n $.ajax({\n url: url,\n type: \"post\",\n dataType: \"json\",\n data: form.serialize(),\n success: function (data) {\n if (!data.success) {\n recaptchaUtils.resetGRecaptcha();\n formValidation(form, data);\n handleLoginFormButton(loginButton, isRecaptchaEnabled);\n form.spinner().stop();\n } else {\n $(\"form.login\").trigger(\"login:success\", data);\n const urlRedirect = $(\"#url-redirect-to-account-show\").val();\n\n location.href = urlRedirect;\n }\n },\n error: function (data) {\n if (data.responseJSON.redirectUrl) {\n window.location.href = data.responseJSON.redirectUrl;\n } else {\n recaptchaUtils.resetGRecaptcha();\n form.spinner().stop();\n formValidation(form, data);\n handleLoginFormButton(loginButton, isRecaptchaEnabled);\n form.spinner().stop();\n }\n }\n });\n return false;\n };\n\n try {\n recaptchaUtils.renderGRecaptchaIfRequired(callback);\n } catch (e) {\n $.spinner().stop();\n }\n });\n },\n\n register: function () {\n const submit = (e) => {\n e.preventDefault();\n const $form = $(e.target).closest(\"form\");\n const isValid = $form[0].checkValidity();\n const $emailInput = $(\"#registration-form-email\");\n const emailAlreadyInUseErrorMsg = $emailInput.data(\"already-in-use-email\");\n const $rutInput = $(\"#registration-form-rut\");\n const rutAlreadyInUseErrorMsg = $rutInput.data(\"already-in-use-rut\");\n\n if (!isValid) {\n return;\n }\n\n $.spinner().start();\n const url = $form.attr(\"action\");\n const $notification = $(\".notification-alert\");\n\n $.ajax({\n url: url,\n type: \"post\",\n dataType: \"json\",\n data: $form.serialize(),\n success: function (data) {\n $.spinner().stop();\n\n if (!data.success) {\n if (data.hasCustomerWithSameEmail) {\n $emailInput.addClass(\"is-invalid\");\n $emailInput.siblings(\".invalid-feedback\").text(emailAlreadyInUseErrorMsg);\n\n return;\n }\n if (data.hasCustomerWithSameRUT) {\n $rutInput.addClass(\"is-invalid\");\n $rutInput.siblings(\".invalid-feedback\").text(rutAlreadyInUseErrorMsg);\n\n return;\n }\n\n formValidation($form, data);\n } else {\n gtm.gtmSignUp();\n location.href = data.redirectUrl;\n }\n },\n error: function (data) {\n if (data.responseJSON.redirectUrl) {\n window.location.href = data.responseJSON.redirectUrl;\n } else {\n $.spinner().stop();\n utilsServices.createErrorNotification(data.responseJSON.errorMessage, $notification);\n }\n }\n });\n };\n\n $(\".registration .submit-btn-form\").on(\"click\", (e) => {\n submit(e);\n });\n },\n\n resetPassword: function () {\n $(\".reset-password-form\").submit(function (e) {\n var form = $(this);\n e.preventDefault();\n var url = form.attr(\"action\");\n form.spinner().start();\n $(\".reset-password-form\").trigger(\"login:register\", e);\n $.ajax({\n url: url,\n type: \"post\",\n dataType: \"json\",\n data: form.serialize(),\n success: function (data) {\n form.spinner().stop();\n if (!data.success) {\n formValidation(form, data);\n } else {\n $(\".request-password-title\").text(data.receivedMsgHeading);\n $(\".request-password-body\").empty()\n .append(\"

\" + data.receivedMsgBody + \"

\");\n if (!data.mobile) {\n $(\"#submitEmailButton\").text(data.buttonText)\n .attr(\"data-dismiss\", \"modal\");\n } else {\n $(\".send-email-btn\").empty()\n .html(\"\"\n + data.buttonText + \"\"\n );\n }\n }\n },\n error: function () {\n form.spinner().stop();\n }\n });\n return false;\n });\n },\n\n clearResetForm: function () {\n $(\"#login .modal\").on(\"hidden.bs.modal\", function () {\n $(\"#reset-password-email\").val(\"\");\n $(\".modal-dialog .form-control.is-invalid\").removeClass(\"is-invalid\");\n });\n },\n\n submitSocialLoginForm: function () {\n const submit = (e) => {\n e.preventDefault();\n const $form = $(e.target).closest(\"form\");\n const isValid = $form[0].checkValidity();\n\n if (!isValid) {\n return;\n }\n\n $.spinner().start();\n const url = $form.attr(\"action\");\n const $notification = $(\".notification-alert\");\n\n $.ajax({\n url: url,\n type: \"post\",\n dataType: \"json\",\n data: $form.serialize(),\n success: function (data) {\n $form.spinner().stop();\n\n if (!data.success) {\n if (data.hasCustomerWithSameEmail) {\n showErrorEmailRegistered();\n return;\n }\n\n formValidation($form, data);\n } else {\n const urlRedirect = $(\"#url-redirect-to-account-show\").attr(\"value\");\n location.href = urlRedirect;\n }\n },\n error: function (data) {\n if (data.responseJSON.redirectUrl) {\n window.location.href = data.responseJSON.redirectUrl;\n } else {\n $form.spinner().stop();\n utilsServices.createErrorNotification(data.responseJSON.errorMessage, $notification);\n }\n }\n });\n };\n\n $(\"#sociallogin-btn\").on(\"click\", (e) => {\n submit(e);\n });\n },\n};\n","\"use strict\";\n\nmodule.exports = {\n maskRUT: function ($elem) {\n var $rutField = $($elem);\n var mask = \"Z0.000.000-A\";\n var rutOptions = {\n onKeyPress : function () {\n $rutField.mask(mask, rutOptions);\n },\n translation : {\n \"Z\" : {\n pattern : /[0-9]/g,\n optional : true\n },\n \"A\" : {\n pattern : /[0-9kK]/g,\n optional : false\n }\n },\n reverse: true\n };\n \n $rutField.mask(mask, rutOptions);\n },\n maskPhone: function ($elem) {\n delete $.jMaskGlobals.translation[\"9\"];\n $($elem).mask(\"+56 9 0000 0000\", {\n translation: {\n \"0\": {\n pattern : /[0-9]/g \n }\n }\n });\n },\n maskBirthdate: function ($elem) {\n $($elem).mask(\"00/00/0000\");\n }\n};\n","\"use strict\";\n\nconst recaptchaContainer = $(\".grecaptcha-container\");\nconst recaptchaSettings = getGRecaptchaConfigurationObject();\nconst $loginBtns = $(\".submit-customer-login, .btn-submit-login\");\n\n/**\n* Retrieves the reCAPTCHA configuration object\n* @returns {Object} - reCAPTCHA configuration object\n* @property {boolean} isEnabled - Indicates if reCAPTCHA is enabled\n* @property {string} siteKey - The reCAPTCHA site key\n* @property {string} isRequiredUrl - The URL for reCAPTCHA requirement\n* @property {string} isValidAnswerUrl - The URL for validating reCAPTCHA answer\n*/\nfunction getGRecaptchaConfigurationObject() {\n const isEnabled = recaptchaContainer.length > 0;\n const siteKey = isEnabled && recaptchaContainer.data(\"recaptcha-sitekey\");\n const isRequiredUrl = isEnabled && recaptchaContainer.data(\"recaptcha-url\");\n\n return {\n isEnabled : !!(isEnabled && siteKey && isRequiredUrl),\n siteKey : siteKey,\n isRequiredUrl : isRequiredUrl,\n };\n}\n\n/**\n* Resets the Google reCAPTCHA widget if it exists on the page\n*/\nfunction resetGRecaptcha() {\n if (recaptchaSettings.isEnabled && grecaptcha.getPageId() !== null) {\n toggleDisableOnLoginButtons(true);\n grecaptcha.reset();\n }\n}\n\n/**\n* Toggles the disabled state of login buttons\n* @param {boolean} disabled - whether the buttons should be disabled\n* @returns {void}\n*/\nfunction toggleDisableOnLoginButtons(disabled) {\n $loginBtns.prop(\"disabled\", disabled);\n}\n\n/**\n* Renders Google reCAPTCHA if it is required\n* @param {Function} callback - the callback function to be executed after rendering reCAPTCHA\n*/\nfunction renderGRecaptchaIfRequired(callback) {\n if (recaptchaSettings.isEnabled) {\n if (verifyGRecaptchaAnswer()) {\n return callback();\n }\n\n $.ajax({\n async: false,\n url: recaptchaSettings.isRequiredUrl,\n method: \"POST\"\n }).done(function (data) {\n if (data.isRecaptchaRequired) {\n resetGRecaptcha();\n\n if (!grecaptcha.getPageId()) {\n toggleDisableOnLoginButtons(true);\n grecaptcha.render(recaptchaContainer[0], {\n sitekey: recaptchaSettings.siteKey,\n lang: \"es\",\n callback: () => {\n toggleDisableOnLoginButtons(false);\n },\n \"expired-callback\": () => {\n toggleDisableOnLoginButtons(true);\n }\n });\n }\n\n $.spinner().stop();\n return false;\n }\n\n return callback();\n });\n\n return false;\n }\n\n callback();\n}\n\n/**\n* Verifies the Google reCAPTCHA answer and executes the callback function if the answer is valid\n* @param {Function} callback - the callback function to be executed if the reCAPTCHA answer is valid\n* @returns {jQuery.Deferred} - a jQuery deferred object representing the result of the reCAPTCHA verification\n*/\nfunction verifyGRecaptchaAnswer() {\n return grecaptcha.getPageId() !== null;\n}\n\nmodule.exports = {\n getGRecaptchaConfigurationObject: getGRecaptchaConfigurationObject,\n renderGRecaptchaIfRequired: renderGRecaptchaIfRequired,\n verifyGRecaptchaAnswer: verifyGRecaptchaAnswer,\n resetGRecaptcha: resetGRecaptcha\n};\n","\"use strict\";\n\n/**\n* Sets a timeout to clear the HTML content of the specified element reference\n* @param {jQuery} $elementRef - the jQuery element reference to update\n* @param {number} timeOut - the time in milliseconds before clearing the content\n* @returns {void}\n*/\nfunction setNotificationTimeout($elementRef, timeOut) {\n setTimeout(() => {\n $elementRef.html(\"\");\n }, timeOut);\n}\n\nmodule.exports = {\n createErrorNotification: function (message, $elementRef, hasSetTimeout = false, timeOut = 3000) {\n const errorHtml = `\n
\n ${hasSetTimeout ? \"\" : `\n \n ×\n \n `}\n ${message}\n
\n `;\n\n $($elementRef).append(errorHtml);\n if (hasSetTimeout) {\n setNotificationTimeout($elementRef, timeOut);\n }\n },\n\n createSuccessNotification: function (message, $elementRef, hasSetTimeout = false, timeOut = 3000) {\n const successHtml = `\n
\n ${hasSetTimeout ? \"\" : `\n \n `}\n ${message}\n
\n `;\n\n $($elementRef).css({\n \"left\": \"auto\",\n \"right\": \"10px\"\n });\n\n $($elementRef).append(successHtml);\n\n if (hasSetTimeout) {\n setNotificationTimeout($elementRef, timeOut);\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","// 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$(document).ready(function () {\n processInclude(require(\"./login/login\"));\n});\n"],"names":[],"sourceRoot":""}