{"version":3,"file":"default/js/gtm.js","mappings":";;;;;;;;;AAAA;AACA,IAAI,KAAyC;AAC7C,IAAI,iCAAO,EAAE,mCAAE;AACf;AACA,KAAK;AAAA,kGAAC,GAAG,CAGsD;AAC/D,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8CAA8C,yBAAyB;AACvE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wFAAwF;AACxF;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB;AACjB;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B,qBAAqB;AAChD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iCAAiC;AACjC;AACA,8BAA8B;AAC9B;AACA;AACA;AACA,0BAA0B;AAC1B;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyB;AACzB;AACA;AACA;AACA;AACA,6BAA6B,gEAAgE;AAC7F;AACA;AACA;AACA,CAAC;;;;;;UCzGD;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;;;;;;;;ACtBa;;AAEb;AACA;AACA,WAAW,QAAQ;AACnB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,6BAA6B;AAC7B;AACA,aAAa;AACb;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,kCAAkC;AAClC;AACA;AACA;;AAEA;AACA;AACA,WAAW,QAAQ;AACnB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,QAAQ;AACnB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,6EAA6E;AAC7E;AACA,KAAK;AACL;AACA,sBAAsB;AACtB;AACA;;AAEA;AACA,yDAAyD;AACzD;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA,CAAC;;;;;;;;ACxKD,mBAAO,CAAC,yEAAe,IAAI","sources":["webpack://sfra-startup-kit/./node_modules/svg4everybody/dist/svg4everybody.js","webpack://sfra-startup-kit/webpack/bootstrap","webpack://sfra-startup-kit/./cartridges/int_gtm/cartridge/client/default/js/gtm.js","webpack://sfra-startup-kit/./node_modules/svg-spritemap-webpack-plugin/svg4everybody-helper.js"],"sourcesContent":["!function(root, factory) {\n \"function\" == typeof define && define.amd ? // AMD. Register as an anonymous module unless amdModuleId is set\n define([], function() {\n return root.svg4everybody = factory();\n }) : \"object\" == typeof module && module.exports ? // Node. Does not work with strict CommonJS, but\n // only CommonJS-like environments that support module.exports,\n // like Node.\n module.exports = factory() : root.svg4everybody = factory();\n}(this, function() {\n /*! svg4everybody v2.1.9 | github.com/jonathantneal/svg4everybody */\n function embed(parent, svg, target) {\n // if the target exists\n if (target) {\n // create a document fragment to hold the contents of the target\n var fragment = document.createDocumentFragment(), viewBox = !svg.hasAttribute(\"viewBox\") && target.getAttribute(\"viewBox\");\n // conditionally set the viewBox on the svg\n viewBox && svg.setAttribute(\"viewBox\", viewBox);\n // copy the contents of the clone into the fragment\n for (// clone the target\n var clone = target.cloneNode(!0); clone.childNodes.length; ) {\n fragment.appendChild(clone.firstChild);\n }\n // append the fragment into the svg\n parent.appendChild(fragment);\n }\n }\n function loadreadystatechange(xhr) {\n // listen to changes in the request\n xhr.onreadystatechange = function() {\n // if the request is ready\n if (4 === xhr.readyState) {\n // get the cached html document\n var cachedDocument = xhr._cachedDocument;\n // ensure the cached html document based on the xhr response\n cachedDocument || (cachedDocument = xhr._cachedDocument = document.implementation.createHTMLDocument(\"\"), \n cachedDocument.body.innerHTML = xhr.responseText, xhr._cachedTarget = {}), // clear the xhr embeds list and embed each item\n xhr._embeds.splice(0).map(function(item) {\n // get the cached target\n var target = xhr._cachedTarget[item.id];\n // ensure the cached target\n target || (target = xhr._cachedTarget[item.id] = cachedDocument.getElementById(item.id)), \n // embed the target into the svg\n embed(item.parent, item.svg, target);\n });\n }\n }, // test the ready state change immediately\n xhr.onreadystatechange();\n }\n function svg4everybody(rawopts) {\n function oninterval() {\n // while the index exists in the live collection\n for (// get the cached index\n var index = 0; index < uses.length; ) {\n // get the current \n var use = uses[index], parent = use.parentNode, svg = getSVGAncestor(parent), src = use.getAttribute(\"xlink:href\") || use.getAttribute(\"href\");\n if (!src && opts.attributeName && (src = use.getAttribute(opts.attributeName)), \n svg && src) {\n if (polyfill) {\n if (!opts.validate || opts.validate(src, svg, use)) {\n // remove the element\n parent.removeChild(use);\n // parse the src and get the url and id\n var srcSplit = src.split(\"#\"), url = srcSplit.shift(), id = srcSplit.join(\"#\");\n // if the link is external\n if (url.length) {\n // get the cached xhr request\n var xhr = requests[url];\n // ensure the xhr request exists\n xhr || (xhr = requests[url] = new XMLHttpRequest(), xhr.open(\"GET\", url), xhr.send(), \n xhr._embeds = []), // add the svg and id as an item to the xhr embeds list\n xhr._embeds.push({\n parent: parent,\n svg: svg,\n id: id\n }), // prepare the xhr ready state change event\n loadreadystatechange(xhr);\n } else {\n // embed the local id into the svg\n embed(parent, svg, document.getElementById(id));\n }\n } else {\n // increase the index when the previous value was not \"valid\"\n ++index, ++numberOfSvgUseElementsToBypass;\n }\n }\n } else {\n // increase the index when the previous value was not \"valid\"\n ++index;\n }\n }\n // continue the interval\n (!uses.length || uses.length - numberOfSvgUseElementsToBypass > 0) && requestAnimationFrame(oninterval, 67);\n }\n var polyfill, opts = Object(rawopts), newerIEUA = /\\bTrident\\/[567]\\b|\\bMSIE (?:9|10)\\.0\\b/, webkitUA = /\\bAppleWebKit\\/(\\d+)\\b/, olderEdgeUA = /\\bEdge\\/12\\.(\\d+)\\b/, edgeUA = /\\bEdge\\/.(\\d+)\\b/, inIframe = window.top !== window.self;\n polyfill = \"polyfill\" in opts ? opts.polyfill : newerIEUA.test(navigator.userAgent) || (navigator.userAgent.match(olderEdgeUA) || [])[1] < 10547 || (navigator.userAgent.match(webkitUA) || [])[1] < 537 || edgeUA.test(navigator.userAgent) && inIframe;\n // create xhr requests object\n var requests = {}, requestAnimationFrame = window.requestAnimationFrame || setTimeout, uses = document.getElementsByTagName(\"use\"), numberOfSvgUseElementsToBypass = 0;\n // conditionally start the interval if the polyfill is active\n polyfill && oninterval();\n }\n function getSVGAncestor(node) {\n for (var svg = node; \"svg\" !== svg.nodeName.toLowerCase() && (svg = svg.parentNode); ) {}\n return svg;\n }\n return svg4everybody;\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].call(module.exports, module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","\"use strict\";\n\n/**\n * function to push data to the dataLayer, and add hash\n * @param {Object} data - data to push\n */\nfunction dataPush(data) {\n if (data) {\n if (data.eventType) {\n delete data.eventType;\n }\n\n // Clear the previous ecommerce object.\n if (\"ecommerce\" in data && !!data.ecommerce) {\n dataLayer.push({ // eslint-disable-line\n ecommerce: null\n });\n }\n\n // Handle navigation after the ecommerce data has been sent to Google Analytics.\n if (data.eventRedirect) {\n var redirectUrl = data.eventRedirect;\n data.eventCallback = function () {\n document.location = redirectUrl;\n };\n delete data.eventRedirect;\n }\n\n if ((location.hash.indexOf(data.event + \"gtm\") == -1)) {\n dataLayer.push(data); // eslint-disable-line\n }\n }\n}\n\n/**\n * Parse the data object into json\n * @param {String} data\n * @returns {Object} jsonObject\n */\nfunction parseJSON(data) {\n var parsedJson = {};\n try {\n parsedJson = JSON.parse(data);\n } catch (error) {\n parsedJson = null;\n }\n return parsedJson;\n}\n\n/**\n * find, parse and add to dataLayer data-gtm from all tags in node\n * @param {Object} node - DOM node, inside which will be search\n */\nfunction findAllDataDOM(node) {\n var allGTMData = $(node).find(\"[data-gtm]\");\n var itemData = {};\n var dataCollectionObj = {};\n\n if (!allGTMData.length) {\n return false;\n }\n\n $.each(allGTMData, function (i) {\n var tempNode = allGTMData[i];\n dataCollectionObj = parseJSON($(tempNode).attr(\"data-gtm\"));\n\n if (!dataCollectionObj || !dataCollectionObj.eventType || !dataCollectionObj.ecommerce) {\n return;\n }\n\n if (dataCollectionObj.eventType.indexOf(\"show\") != -1) {\n if (Object.keys(itemData).length === 0) {\n // Prevent adding the same promoView event in case of loop slider.\n if (!$(tempNode).parent().hasClass(\"swiper-slide-duplicate\")) {\n Object.assign(itemData, dataCollectionObj);\n }\n } else {\n if (\"impressions\" in itemData.ecommerce) {\n itemData.ecommerce.impressions.push(dataCollectionObj.ecommerce.impressions[0]);\n } else if (\"promoView\" in itemData.ecommerce) {\n // Prevent adding the same promoView event in case of loop slider.\n if (!$(tempNode).parent().hasClass(\"swiper-slide-duplicate\")) {\n itemData.ecommerce.promoView.promotions.push(dataCollectionObj.ecommerce.promoView.promotions[0]);\n }\n }\n }\n $(tempNode).removeAttr(\"data-gtm\");\n }\n });\n\n if (Object.keys(itemData).length !== 0) {\n dataPush(itemData);\n }\n}\n\n/**\n * run AJAX/Fetch listener, to find all (gtm_data in JSON) or (gtm-data in HTML).\n */\nfunction GTMListenerRun() {\n // Fetch Listener\n const fetch = window.fetch;\n window.fetch = (...args) => (async (args) => {\n var result = await fetch(...args);\n var res = result.clone();\n const contentType = res.headers.get(\"content-type\");\n if (contentType && contentType.indexOf(\"application/json\") > -1) {\n var resJson = res.json();\n resJson.then(data => {\n if (data.gtm_data) {\n dataPush(data.gtm_data);\n }\n });\n }\n return result;\n })(args);\n\n // AJAX Listener\n var listenerSend = XMLHttpRequest.prototype.send;\n XMLHttpRequest.prototype.send = function () {\n var callback = this.onreadystatechange;\n this.onreadystatechange = function () {\n if (this.readyState == 4 && this.status == 200) {\n if (this.getAllResponseHeaders().indexOf(\"application/json\") != -1) {\n var myArr = parseJSON(this.response);\n if (myArr.gtm_data) {\n var parsedGTM = parseJSON(myArr.gtm_data);\n dataPush(parsedGTM);\n }\n }\n }\n if (callback) {\n callback.apply(this, arguments);\n }\n };\n listenerSend.apply(this, arguments);\n };\n}\n\n//run DOM updates listener, to find all gtm-data added to DOM\nfunction DOMListenerRun() {\n var observer = new MutationObserver(function (mutationsList, observer) { // eslint-disable-line\n findAllDataDOM(document);\n });\n var targetNode = document.body,\n config = {childList: true, subtree: true};\n observer.observe(targetNode, config);\n}\n\nfunction clickListenerRun() {\n $(document).on(\"click\", \"[data-gtm]\", function (e) { // eslint-disable-line\n var gtmElement = parseJSON(e.currentTarget.getAttribute(\"data-gtm\"));\n\n // prevent default redirect to properly sent dataLayer and then do redirect.\n if (gtmElement && gtmElement.eventRedirect) {\n e.preventDefault();\n }\n\n if (gtmElement && gtmElement.eventType && gtmElement.eventType.indexOf(\"click\") !== -1) {\n dataPush(gtmElement);\n }\n });\n}\n\ndocument.addEventListener(\"DOMContentLoaded\", function () {\n DOMListenerRun();\n findAllDataDOM(document);\n GTMListenerRun();\n clickListenerRun();\n});\n","require('svg4everybody')({});\n"],"names":[],"sourceRoot":""}