{"version":3,"file":"product_list.min.js","sources":["product_list.js"],"sourcesContent":["// reset redirecting flag in case back button was clicked in the browser\nwindow.addEventListener('pageshow', function () { window.isBeingRedirected = false; });\n\n(($, w) => {\n const gtmImpressionsChunkSize = 30;\n const assetId = 'gtm-eec-prod-list';\n\n let userInfo = null;\n if (w.umwAssets && w.umwAssets[assetId] && w.umwAssets[assetId].length) {\n userInfo = w.umwAssets[assetId][0];\n }\n\n w.PubSub.subscribe('externaltracking.product.listview', (_, productImpressions) => {\n if (productImpressions && productImpressions.items && productImpressions.items.length > 0) {\n processImpressions(productImpressions);\n }\n });\n\n function processImpressions(productListImpressions) {\n const listName = productListImpressions.listName || document.title;\n const allProducts = productListImpressions.items;\n const totalProductsCount = allProducts.length;\n var $allProductLinks = $(); \n var idx = 0, chunkIdx = 0;\n const utils = new GtmUtils();\n const currencyCode = utils.getCurrencyCode(productListImpressions);\n while (idx < totalProductsCount) {\n const positionShift = chunkIdx * gtmImpressionsChunkSize;\n\n const products = allProducts.slice(idx, idx += gtmImpressionsChunkSize);\n const gtmProducts = [];\n\n for (var i = 0, l = products.length; i < l; i++) {\n const prod = products[i];\n const positionInList = positionShift + i + 1;\n const gtmProd = utils.convertToGtmEecProduct(prod, { 'list': listName, 'position': positionInList });\n if (gtmProd) {\n gtmProducts.push(gtmProd);\n\n if (prod.$links) {\n prod.$links.data('gtm-product', gtmProd);\n prod.$links.data('listname', listName);\n prod.$links.data('currencycode', currencyCode);\n\n $allProductLinks = $allProductLinks.add(prod.$links);\n }\n }\n }\n\n const impressionViewEvent = {\n 'event': 'eec.impressionView',\n 'ecommerce': {\n 'currencyCode': currencyCode,\n 'impressions': gtmProducts\n }\n };\n \n if (userInfo) {\n impressionViewEvent.user = userInfo;\n }\n\n w.dataLayer.push({ ecommerce: null }); // Clear the previous ecommerce object.\n w.dataLayer.push(impressionViewEvent);\n\n ++chunkIdx;\n }\n\n if ($allProductLinks.length > 0) {\n $allProductLinks.on('click', function (evt) {\n try {\n if (w['google_tag_manager']) {\n var targetUrl = this.href;\n const $this = $(this);\n\n const productClickEvent = {\n 'event': 'eec.productClick',\n 'ecommerce': {\n 'currencyCode': $this.data('currencycode') || utils.getCurrencyCode(),\n 'click': {\n 'actionField': { 'list': $this.data('listname') },\n 'products': [$this.data('gtm-product')]\n }\n },\n 'eventCallback': function () {\n if (!w.isBeingRedirected) {\n document.location = targetUrl;\n w.isBeingRedirected = true;\n }\n },\n 'eventTimeout': 1000\n };\n\n w.dataLayer.push({ ecommerce: null }); // Clear the previous ecommerce object.\n w.dataLayer.push(productClickEvent);\n\n evt.preventDefault();\n }\n } catch (e) {\n console.error('[GTM]: Failed to push product click event to dataLayer. Reason: ' + e);\n }\n });\n }\n }\n})(jQuery, window);"],"names":["window","addEventListener","isBeingRedirected","$","w","assetId","let","userInfo","umwAssets","length","PubSub","subscribe","_","productImpressions","items","processImpressions","listName","productListImpressions","document","title","allProducts","totalProductsCount","$allProductLinks","idx","chunkIdx","utils","GtmUtils","currencyCode","getCurrencyCode","positionShift","products","slice","gtmProducts","i","l","prod","positionInList","gtmProd","convertToGtmEecProduct","list","position","push","$links","data","add","impressionViewEvent","event","ecommerce","impressions","user","dataLayer","on","evt","targetUrl","this","href","$this","productClickEvent","click","actionField","eventCallback","location","eventTimeout","preventDefault","e","console","error","jQuery"],"mappings":"AACAA,OAAOC,iBAAiB,WAAY,WAAcD,OAAOE,mBAAoB,KAE7E,CAAEC,EAAGC,KAED,IAAMC,EAAU,oBAEhBC,IAAIC,EAAW,KACXH,EAAEI,WAAaJ,EAAEI,UAAUH,IAAYD,EAAEI,UAAUH,GAASI,SAC5DF,EAAWH,EAAEI,UAAUH,GAAS,IAGpCD,EAAEM,OAAOC,UAAU,oCAAqC,CAACC,EAAGC,KACxD,GAAIA,GAAsBA,EAAmBC,OAA2C,EAAlCD,EAAmBC,MAAML,OAC3EM,CAKJ,MAAMC,EAAWC,EAAuBD,UAAYE,SAASC,MACvDC,EAAcH,EAAuBH,MACrCO,EAAqBD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