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,EAAMR,EAAMS,cAAc,OAE9B,OAAID,GAAOA,EAAIE,IACJF,EAAIE,IAGR,EACX,EGlDa,CACTC,gBAAiB,WCDVC,MAAM,wDAADC,OADqB,KAG/BC,MAAK,SAAAC,GAAQ,OAAIA,EAASC,MAAM,IDERF,MAAK,SAAAG,GACnBA,GAAQA,EAAKC,UAAYD,EAAKC,SAASC,OAHP,GAIhC,wDAA0BL,MAAK,SAAA1C,GAAqB,OAAAA,EAAA,QAAiBgD,KAAKH,EAAK,GAEvF,GACJ,EACAI,gBAAiB,WACb,yDAA0BP,MAAK,SAAAjD,GAA2B,OAAAA,EAAA,QAAuBuD,MAAM,GAC3F,EACAE,2BAA4B,WAAF,OAAQ5D,GAA4B,EAC9D0D,KAAM,WACFG,KAAKZ,kBACLY,KAAKF,kBAED5C,OAAO+C,WACP,+BAAyBV,MAAK,SAAAhD,GAAqB,OAAO0D,EAAP1D,EAAA,SAAiBI,SAASuC,cAAc,gBAAiBhC,OAAO+C,UAAU,IAGjID,KAAKD,4BACT,IExBCF,M,YCFLK,EAAOC,QAAUC,M","sources":["webpack://front-end-build-system/./src/dom/elementintersectionobserver.js","webpack://front-end-build-system/./src/views/home/contentblockeventlisteners.js","webpack://front-end-build-system/./src/vendor/googletagmanager/spevents/sphomepagecontentview.js","webpack://front-end-build-system/./src/vendor/googletagmanager/spevents/sphomepagecontentclick.js","webpack://front-end-build-system/./src/views/home/home.js","webpack://front-end-build-system/./src/views/home/fetchbuyitagaindata.js","webpack://front-end-build-system/./src/views/home/index.js","webpack://front-end-build-system/external var \"jQuery\""],"sourcesContent":["export default function elementIntersectionObserver(options) {\n const map = new Map(),\n observer = new IntersectionObserver(function(entries) {\n entries.forEach(entry => {\n if (entry.isIntersecting && map.has(entry.target)) {\n map.get(entry.target)(entry.target);\n map.delete(entry.target);\n observer.unobserve(entry.target);\n }\n });\n }, Object.assign({rootMargin: '320px', threshold: 0}, options || {}));\n\n return function(element, callback) {\n if (!element || typeof callback !== 'function') {\n throw new Error('An elementIntersectionObserver requires an element reference and a callback function');\n }\n\n map.set(element, callback);\n observer.observe(element);\n\n return observer;\n };\n}\n"," \nimport elementIntersectionObserver from '../../dom/elementintersectionobserver.js';\nimport { spHomepageContentClick } from '../../vendor/googletagmanager/spevents/sphomepagecontentclick.js';\nimport { spHomepageContentView } from '../../vendor/googletagmanager/spevents/sphomepagecontentview.js';\n\nconst contentBlockNameSelectorMap = {\n 'hero': '.hero',\n 'seasonal': '.seasonal-link',\n 'policies': '.messaging-item',\n 'shop supplement carousel': '.supplement.categories .carousel-item',\n 'shop tes carousel': '.tes.categories .carousel-item',\n 'brands': '.brand-link',\n 'health resources': '.resource-item',\n 'image banner': '.cta-banner'\n};\n\nexport default function contentBlockEventListeners() {\n const whenInView = elementIntersectionObserver({ rootMargin: '0px', threshold: 0.5 });\n\n getBlocksFromMapObject(contentBlockNameSelectorMap)\n .forEach(({ $elements, name }) => {\n $elements.forEach(($element, index) => whenInView($element, () => handleWhenInView({ $element, position: index + 1, name })));\n });\n}\n\nfunction getBlocksFromMapObject(mappingObject) {\n return Object.entries(mappingObject).map(([name, selector]) => ({\n $elements: document.querySelectorAll(selector),\n name\n }));\n}\n\nfunction handleWhenInView({ $element, position, name }) {\n spHomepageContentView({ name, position });\n addContentClickListeners({ $element, position, name });\n}\n\nfunction discoverText($link) {\n if ($link.innerText) {\n return $link.innerText.split('\\n')[0];\n }\n\n if ($link.hasAttribute('aria-label')) {\n return $link.getAttribute('aria-label');\n }\n\n let img = $link.querySelector('img');\n\n if (img && img.alt) {\n return img.alt;\n }\n\n return '';\n}\n\nfunction addContentClickListeners({ $element, position, name }) {\n const handleClick = (e) => spHomepageContentClick({\n name,\n position,\n url: e.currentTarget.href,\n text: discoverText(e.currentTarget)\n });\n\n if ($element.nodeName.toLowerCase() === 'a') {\n $element.addEventListener('click', e => handleClick(e));\n return;\n }\n\n Array.from($element.querySelectorAll('a'))\n .forEach($link => $link.addEventListener('click', e => handleClick(e)));\n}\n","/* eslint-disable camelcase */\nexport function spHomepageContentView({ name, position }) {\n window.dataLayer = window.dataLayer || [];\n window.dataLayer.push({\n event: 'sp_homepage_content_view',\n content_block: name,\n content_block_position: position.toString()\n });\n}","/* eslint-disable camelcase */\nexport function spHomepageContentClick({ name, position, url, text }) {\n window.dataLayer = window.dataLayer || [];\n window.dataLayer.push({\n event: 'sp_homepage_content_click',\n content_block: name,\n content_block_position: position.toString(),\n click_url: url,\n click_text: text\n });\n}\n","import contentBlockEventListeners from './contentblockeventlisteners';\nimport fetchBuyItAgainData from './fetchbuyitagaindata';\n\nconst home = {\n setupBuyItAgain: function () {\n const minimumAmountOfProductsRequired = 4;\n\n fetchBuyItAgainData().then(data => {\n if (data && data.products && data.products.length > minimumAmountOfProductsRequired) {\n import('./buyitagain.js').then(({default: buyItAgain}) => buyItAgain.init(data));\n }\n });\n },\n setupCategories: function () {\n import('./categories.js').then(({default: categoriesSlider}) => categoriesSlider.init());\n },\n setupContentEventListeners: () => contentBlockEventListeners(),\n init: function () {\n this.setupBuyItAgain();\n this.setupCategories();\n\n if (window.videoHero) {\n import('./videohero.js').then(({ default: videoHero }) => videoHero(document.querySelector('.hero .image'), window.videoHero));\n }\n\n this.setupContentEventListeners();\n }\n};\n\n\nexport default home;\n","\nexport default function fetchBuyItAgainData(){\n const numberOfProductsReturned = 18;\n return fetch(\n `/api/BuyAgain/GetBuyAgainSuggestions?requestedNumber=${numberOfProductsReturned}`\n ).then(response => response.json());\n}","import home from './home.js';\n\nhome.init();","module.exports = jQuery;"],"names":["elementIntersectionObserver","options","map","Map","observer","IntersectionObserver","entries","forEach","entry","isIntersecting","has","target","get","unobserve","Object","assign","rootMargin","threshold","element","callback","Error","set","observe","contentBlockNameSelectorMap","contentBlockEventListeners","mappingObject","whenInView","_ref2","_ref3","name","selector","$elements","document","querySelectorAll","_ref","$element","index","_ref4","position","window","dataLayer","push","event","content_block","content_block_position","toString","spHomepageContentView","_ref5","handleClick","e","url","text","click_url","click_text","spHomepageContentClick","currentTarget","href","discoverText","nodeName","toLowerCase","Array","from","$link","addEventListener","addContentClickListeners","handleWhenInView","innerText","split","hasAttribute","getAttribute","img","querySelector","alt","setupBuyItAgain","fetch","concat","then","response","json","data","products","length","init","setupCategories","setupContentEventListeners","this","videoHero","module","exports","jQuery"],"sourceRoot":""}