{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./codebase/orange/cartridges/app_storefront_core/cartridge/client/default/js/dataLayer/analytics.js","webpack:///./codebase/orange/cartridges/app_storefront_core/cartridge/client/default/js/dataLayer/button.js","webpack:///./codebase/orange/cartridges/app_storefront_core/cartridge/client/default/js/dataLayer/dataLayer.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;;AAEa;;AAEb;AACA;AACA;AACA,UAAU,OAAO;AACjB,UAAU,OAAO;AACjB,UAAU,OAAO;AACjB,UAAU,OAAO;AACjB,UAAU,OAAO;AACjB,UAAU,OAAO;AACjB,UAAU,OAAO;AACjB,UAAU,OAAO;AACjB,UAAU,OAAO;AACjB,UAAU,OAAO;AACjB,UAAU,OAAO;AACjB,UAAU,OAAO;AACjB,UAAU,OAAO;AACjB,UAAU,OAAO;AACjB,UAAU,OAAO;AACjB,YAAY,cAAc;AAC1B;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA,UAAU,OAAO;AACjB,UAAU,OAAO;AACjB,UAAU,OAAO;AACjB,UAAU,OAAO;AACjB,UAAU,OAAO;AACjB,UAAU,OAAO;AACjB,UAAU,OAAO;AACjB,UAAU,OAAO;AACjB,UAAU,OAAO;AACjB,UAAU,OAAO;AACjB,UAAU,OAAO;AACjB,UAAU,OAAO;AACjB,UAAU,OAAO;AACjB,UAAU,OAAO;AACjB,YAAY,cAAc;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,cAAc;AACzB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA,UAAU,OAAO;AACjB,UAAU,OAAO;AACjB,UAAU,OAAO;AACjB,UAAU,OAAO;AACjB,UAAU,cAAc;AACxB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA,UAAU,OAAO;AACjB,UAAU,OAAO;AACjB,UAAU,cAAc;AACxB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU,OAAO;AACjB,UAAU,OAAO;AACjB,UAAU,cAAc;AACxB,YAAY;AACZ;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA,UAAU,OAAO;AACjB,UAAU,OAAO;AACjB,UAAU,OAAO;AACjB,UAAU,OAAO;AACjB,UAAU,MAAM;AAChB,UAAU,OAAO;AACjB,UAAU,OAAO;AACjB,UAAU,OAAO;AACjB,UAAU,OAAO;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;ACjOa;;AAEb,sBAAsB,mBAAO,CAAC,qIAA0B;AACxD,sBAAsB,mBAAO,CAAC,qIAA0B;;AAExD;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA,CAAC;;AAED;AACA;AACA;AACA;AACA;;;;;;;;;;;;;AC9CA;AACA;;AAEa;;AAEb;AACA;AACA,aAAa,OAAO;AACpB;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,OAAO;AACpB;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA,yBAAyB;AACzB;AACA;AACA;AACA,aAAa;AACb;AACA,aAAa;AACb,SAAS;AACT;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB;AACA;AACA;AACA;AACA;AACA,SAAS;;AAET;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,MAAM;AACjB,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;;AAET;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uHAAuH;AACvH;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA","file":"default\\js\\dataLayer\\button.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 = \"./codebase/orange/cartridges/app_storefront_core/cartridge/client/default/js/dataLayer/button.js\");\n","/* eslint-disable camelcase */\r\n\r\n'use strict';\r\n\r\n/**\r\n* Builds an array of item objects based on the provided product details.\r\n*\r\n* @param {Object} product - The product object containing various attributes.\r\n* @param {string} product.ID - The unique identifier of the product.\r\n* @param {string} product.name - The name of the product.\r\n* @param {string} [product.affiliation] - The affiliation or store name where the product is sold.\r\n* @param {string} [product.coupon] - The coupon code applied to the product.\r\n* @param {number} [product.discount] - The discount amount applied to the product.\r\n* @param {string} [product.currency] - The currency in which the product price is denoted.\r\n* @param {number} [product.index] - The index or position of the product in a list.\r\n* @param {string} [product.brand] - The brand of the product.\r\n* @param {string} [product.category] - The category to which the product belongs.\r\n* @param {string} [product.listId] - The identifier of the list containing the product.\r\n* @param {string} [product.list] - The name of the list containing the product.\r\n* @param {string} [product.variant] - The variant of the product.\r\n* @param {number} product.price - The price of the product.\r\n* @param {number} product.quantity - The quantity of the product.\r\n* @returns {Array} An array containing a single item object with the product details.\r\n*/\r\nfunction buildItemsView(product) {\r\n if (!product.item_id || !product.item_name) {\r\n return [];\r\n }\r\n\r\n return [{\r\n item_id: product.item_id,\r\n item_name: product.item_name,\r\n affiliation: product.affiliation,\r\n coupon: product.coupon,\r\n discount: product.discount,\r\n index: product.index || 0,\r\n item_brand: product.item_brand,\r\n item_category: product.item_category,\r\n item_list_id: product.item_list_id,\r\n item_list_name: product.item_list_name,\r\n item_variant: product.item_variant,\r\n price: product.price || 0.00,\r\n quantity: product.quantity || 1\r\n }];\r\n}\r\n\r\n/**\r\n* Constructs an array of item promotion objects based on the provided product details.\r\n*\r\n* @param {Object} product - The product object containing details for the promotion.\r\n* @param {string} product.item_id - The unique identifier for the item.\r\n* @param {string} product.item_name - The name of the item.\r\n* @param {string} [product.affiliation] - The affiliation or store name.\r\n* @param {string} [product.coupon] - The coupon code applied to the item.\r\n* @param {string} [product.discount] - The discount applied to the item, default is '0.00'.\r\n* @param {number} [product.index] - The index of the item in the list.\r\n* @param {string} product.brand - The brand of the item.\r\n* @param {string} product.category - The category of the item.\r\n* @param {string} [product.listId] - The identifier for the item list.\r\n* @param {string} [product.listName] - The name of the item list.\r\n* @param {string} [product.variant] - The variant of the item.\r\n* @param {string} [product.price] - The price of the item, default is '0.00'.\r\n* @param {string} [product.quantity] - The quantity of the item, default is '1'.\r\n* @returns {Array} An array containing the item promotion objects.\r\n*/\r\nfunction buildItemsPromotion(product) {\r\n return [{\r\n item_id: product.item_id,\r\n item_name: product.item_name,\r\n affiliation: product.affiliation,\r\n coupon: product.coupon,\r\n creative_name: product.creative_name,\r\n creative_slot: product.creative_slot,\r\n discount: product.discount,\r\n index: product.index || 0,\r\n item_brand: product.item_brand,\r\n item_category: product.item_category,\r\n item_list_id: product.item_list_id,\r\n item_list_name: product.item_list_name,\r\n item_variant: product.item_variant,\r\n price: product.price || 0.00,\r\n promotion_id: product.promotion_id,\r\n promotion_name: product.promotion_name,\r\n quantity: product.quantity || 1\r\n }];\r\n}\r\n\r\n/**\r\n * Pushes a promotion view event to the data layer for analytics tracking.\r\n *\r\n * @param {string} creativeName - The name of the creative associated with the promotion.\r\n * @param {string} creativeSlot - The slot or placement of the creative.\r\n * @param {string} promotionId - The unique identifier for the promotion.\r\n * @param {string} promotionName - The name of the promotion.\r\n * @param {Array} [items=null] - An optional array of items associated with the promotion.\r\n */\r\nfunction buildDataViewPromotion(creativeName, creativeSlot, promotionId, promotionName, items = null) {\r\n window.dataLayer = window.dataLayer || [];\r\n\r\n window.dataLayer.push({\r\n event: 'view_promotion',\r\n eventModel: {\r\n creative_name: creativeName,\r\n creative_slot: creativeSlot,\r\n promotion_id: promotionId,\r\n promotion_name: promotionName,\r\n items: buildItemsPromotion(items)\r\n }\r\n });\r\n}\r\n\r\n/**\r\n* Builds and pushes a 'select_promotion' event to the dataLayer for analytics tracking.\r\n*\r\n* @param {string} creativeName - The name of the creative associated with the promotion.\r\n* @param {string} creativeSlot - The slot or position where the creative is displayed.\r\n* @param {string} promotionId - The unique identifier for the promotion.\r\n* @param {string} promotionName - The name of the promotion.\r\n* @param {Array} [items=null] - An optional array of items associated with the promotion.\r\n*/\r\nfunction buildDataSelectPromotion(creativeName, creativeSlot, promotionId, promotionName, items = null) {\r\n window.dataLayer = window.dataLayer || [];\r\n\r\n window.dataLayer.push({\r\n event: 'select_promotion',\r\n eventModel: {\r\n creative_name: creativeName,\r\n creative_slot: creativeSlot,\r\n promotion_id: promotionId,\r\n promotion_name: promotionName,\r\n items: buildItemsPromotion(items)\r\n }\r\n });\r\n}\r\n\r\n/**\r\n* Pushes a 'view_item' event to the data layer with the specified currency, value, and items.\r\n* This function is typically used for analytics tracking purposes.\r\n*\r\n* @param {string} currency - The currency code (e.g., 'USD', 'EUR') for the transaction.\r\n* @param {number} value - The total value of the items being viewed.\r\n* @param {Array} items - An array of item objects, where each object represents an item being viewed.\r\n*/\r\nfunction buildDataViewItem(currency, value, items) {\r\n window.dataLayer = window.dataLayer || [];\r\n\r\n window.dataLayer.push({\r\n event: 'view_item',\r\n eventModel: {\r\n currency: currency,\r\n value: value,\r\n items: buildItemsView(items)\r\n }\r\n });\r\n}\r\n\r\n/**\r\n* Builds and pushes a data view item list event to the dataLayer.\r\n*\r\n* This function constructs an event object for viewing an item list and\r\n* pushes it to the global `dataLayer` array. Each item in the provided\r\n* `items` array is processed using the `buildItemsView` function.\r\n*\r\n* @param {string} item_list_id - The unique identifier for the item list.\r\n* @param {string} item_list_name - The name of the item list.\r\n* @param {Array} [items=null] - An optional array of items to be processed and included in the event.\r\n* @returns {void}\r\n*/\r\nfunction buildDataViewItemList(item_list_id, item_list_name, items = null) {\r\n window.dataLayer = window.dataLayer || [];\r\n\r\n const processedItems = items ? items.map(item => buildItemsView(item)) : [];\r\n\r\n window.dataLayer.push({\r\n event: 'view_item_list',\r\n eventModel: {\r\n item_list_id: item_list_id,\r\n item_list_name: item_list_name,\r\n items: processedItems\r\n }\r\n });\r\n}\r\n\r\n/**\r\n* Builds and triggers an analytics event based on the provided event type and data.\r\n*\r\n* @param {string} event - The type of analytics event to build (e.g., 'view_item', 'view_promotion').\r\n* @param {Object} data - The data associated with the event.\r\n* @param {string} data.currency - The currency code (e.g., 'USD') for the 'view_item' event.\r\n* @param {number} data.value - The value of the items for the 'view_item' event.\r\n* @param {Array} data.items - An array of items for the 'view_item' event.\r\n* @param {string} data.creative_name - The creative name for the 'view_promotion' event.\r\n* @param {string} data.creative_slot - The creative slot for the 'view_promotion' event.\r\n* @param {string} data.promotion_id - The promotion ID for the 'view_promotion' event.\r\n* @param {string} data.promotion_name - The promotion name for the 'view_promotion' event.\r\n*/\r\nfunction buildAnalitic(event, data) {\r\n switch (event) {\r\n case 'view_item':\r\n buildDataViewItem(data.currency, data.value, data.items);\r\n break;\r\n case 'view_promotion':\r\n if (data.items.item_id && data.items.item_name) {\r\n buildDataViewPromotion(data.creative_name, data.creative_slot, data.promotion_id, data.promotion_name, data.items);\r\n }\r\n break;\r\n case 'select_promotion':\r\n buildDataSelectPromotion(data.creative_name, data.creative_slot, data.promotion_id, data.promotion_name, data.items);\r\n break;\r\n case 'view_item_list':\r\n buildDataViewItemList(data.item_list_id, data.item_list_name, data.items);\r\n break;\r\n default:\r\n break;\r\n }\r\n}\r\n\r\nmodule.exports = {\r\n buildDataViewPromotion: buildDataViewPromotion,\r\n buildDataViewItem: buildDataViewItem,\r\n buildAnalitic: buildAnalitic,\r\n buildDataViewItemList: buildDataViewItemList,\r\n buildItemsView: buildItemsView,\r\n buildDataSelectPromotion: buildDataSelectPromotion,\r\n buildItemsPromotion: buildItemsPromotion\r\n};\r\n","'use strict';\r\n\r\nvar dataLayerHelper = require('core/dataLayer/dataLayer');\r\nvar analyticsHelper = require('core/dataLayer/analytics');\r\n\r\n/**\r\n * Handles the click event of the buttons with the class 'js-datalayer-btn'\r\n * @returns {undefined}\r\n */\r\nfunction handleBtnOnClick() {\r\n $('.js-datalayer-btn').on('click', function () {\r\n var eventzone = $(this).data('event-zone');\r\n var eventname = $(this).data('event-name');\r\n dataLayerHelper.methods.buildDataLayerEventLink(eventzone, 'clickbutton', eventname);\r\n\r\n var data = {};\r\n\r\n var parentInput = $(this).closest('.data-layout').find('.data-layout__input');\r\n\r\n if (parentInput.length) {\r\n data.creative_name = parentInput.data('creative-name');\r\n data.creative_slot = parentInput.data('creative-slot');\r\n data.promotion_id = parentInput.data('promo-id');\r\n data.promotion_name = parentInput.data('promo-name');\r\n data.items = {\r\n item_id: parentInput.data('promo-id'),\r\n item_name: parentInput.data('promo-name'),\r\n creative_name: parentInput.data('creative-name'),\r\n creative_slot: parentInput.data('creative-slot'),\r\n promotion_id: parentInput.data('promo-id'),\r\n promotion_name: parentInput.data('promo-name')\r\n };\r\n\r\n analyticsHelper.buildAnalitic('select_promotion', data);\r\n }\r\n });\r\n}\r\n\r\n$(document).ready(function () {\r\n handleBtnOnClick();\r\n});\r\n\r\nmodule.exports = {\r\n functions: {\r\n handleBtnOnClick: handleBtnOnClick\r\n }\r\n};\r\n","/* eslint-disable camelcase */\r\n/* eslint-disable no-undef */\r\n\r\n'use strict';\r\n\r\n/**\r\n * Gets the product name from the utag_data object\r\n * @returns {string} the product name or an empty string if not found\r\n */\r\nfunction getProductName() {\r\n return (typeof utag_data !== 'undefined' && utag_data.product_name !== undefined) ? utag_data.product_name : '';\r\n}\r\n\r\n/**\r\n * Gets the product category from utag_data\r\n * @returns {string} the product category from utag_data\r\n */\r\nfunction getProductCategory() {\r\n return (typeof utag_data !== 'undefined' && utag_data.product_category !== undefined) ? utag_data.product_category : '';\r\n}\r\n\r\n/**\r\n * Gets the page category from utag_data\r\n * @returns {string} the page category from utag_data\r\n */\r\nfunction getPageCategory() {\r\n return (typeof utag_data !== 'undefined' && utag_data.pageCategory !== undefined) ? utag_data.pageCategory : '';\r\n}\r\n\r\n/**\r\n * Gets the page name from the utag_data object\r\n * @returns {string} the page name or an empty string if not found\r\n */\r\nfunction getPageName() {\r\n return (typeof utag_data !== 'undefined' && utag_data.pageName !== undefined) ? utag_data.pageName : '';\r\n}\r\n\r\n/**\r\n * Gets the page name from the utag_data object\r\n * @returns {string} the page name without web:orange: or an empty string if not found\r\n */\r\nfunction getPageNameWithoutWebOrange() {\r\n var name = getPageName().replace('web:orange:', '').replace('tiendaOnline:', '');\r\n return name;\r\n}\r\n\r\n/**\r\n * Checks if the user is a client\r\n * @returns {boolean} - true if the user is a client, false otherwise\r\n */\r\nfunction isClient() {\r\n return (typeof utag_data !== 'undefined' && utag_data.userType === 'cliente');\r\n}\r\n\r\n/**\r\n * Returns the page type from utag_data\r\n * @returns {string} - the page type from utag_data\r\n */\r\nfunction getPageType() {\r\n return (typeof utag_data !== 'undefined' && utag_data.pageType !== 'undefined') ? utag_data.pageType : '';\r\n}\r\n\r\n/**\r\n * Builds a data layer event link\r\n * @param {Object} obj - object with data button\r\n * @returns {Promise} A Promise that resolves when the AJAX request is complete and any returned data has been added to the `utag_data` object.\r\n */\r\nfunction addProductToDataLayer(obj) {\r\n return new Promise(function (resolve, reject) {\r\n if (obj.tokenname !== null && obj.token !== null && obj.category !== null && typeof utag_data !== 'undefined') {\r\n var data = {};\r\n data.id = obj.category;\r\n data[obj.tokenname] = obj.token;\r\n $.ajax({\r\n url: obj.url,\r\n type: 'post',\r\n data: data,\r\n dataType: 'json'\r\n }).done((resp) => {\r\n if (resp) {\r\n if (Object.keys(resp.data).length) {\r\n Object.keys(resp.data).forEach(key => {\r\n utag_data[key] = resp.data[key];\r\n });\r\n }\r\n }\r\n resolve();\r\n }).fail(() => {\r\n reject();\r\n });\r\n } else {\r\n reject();\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * Builds a data layer event link\r\n * @param {string} zone - the event zone\r\n * @param {string} type - the event type\r\n * @param {string} name - the event name\r\n * @param {string} [event=null] - the Tealium event (optional)\r\n */\r\nfunction buildDataLayerEventLink(zone, type, name, event = null) {\r\n if (zone && name && typeof utag_data !== 'undefined' && typeof utag !== 'undefined') {\r\n utag_data.event_zone = zone;\r\n utag_data.event_name = name;\r\n utag_data.event_type = type;\r\n if (event !== null) {\r\n utag_data.tealium_event = event;\r\n }\r\n utag.track('link', utag_data);\r\n }\r\n}\r\n\r\n/**\r\n * Builds a data layer event link for the given zone, type, name and event\r\n * @param {string} zone - the zone of the event\r\n * @param {string} type - the type of the event\r\n * @param {string} name - the name of the event\r\n * @param {Object} [event] - the event object (optional)\r\n */\r\nfunction buildDataLayerEventLinkCheckout(zone, type, name, event = null) {\r\n if (typeof utag_data !== 'undefined') {\r\n zone = 'tiendaOnline:' + zone;\r\n if (isClient()) {\r\n zone = 'areaCliente:' + zone;\r\n }\r\n buildDataLayerEventLink(zone, type, name, event);\r\n }\r\n}\r\n\r\n/**\r\n * Builds the data layer view for the given section and data\r\n * @param {string} section - the section of the data layer\r\n * @param {Object} data - the data to be added to the data layer\r\n * @returns {void}\r\n */\r\nfunction buildDataLayerView(section, data) {\r\n if (typeof utag_data !== 'undefined' && typeof utag !== 'undefined') {\r\n var pageData = $('.js-data-layer').data('layer-' + section);\r\n if (pageData !== '') {\r\n utag_data.pageName = pageData.pageName;\r\n utag_data.pageType = pageData.pageType;\r\n var step = pageData.pageType.split(':');\r\n utag_data.checkoutStep = step[1].replace('paso', '');\r\n utag_data.pageVirtual = window.location.protocol + '//' + utag_data['dom.domain'] + utag_data['dom.pathname'];\r\n if (utag_data['dom.pathname'].slice(-1) !== '/') {\r\n utag_data.pageVirtual += '/';\r\n }\r\n utag_data.pageVirtual += pageData.stepID;\r\n }\r\n utag_data.tealium_event = 'checkout';\r\n if (Object.keys(data).length) {\r\n Object.keys(data).forEach(key => {\r\n utag_data[key] = data[key];\r\n });\r\n }\r\n\r\n // load again the view data\r\n utag.track('view', utag_data);\r\n\r\n // replace variable in script\r\n // eslint-disable-next-line no-use-before-define\r\n replaceScript();\r\n }\r\n}\r\n\r\n/**\r\n * Builds the data layer view general\r\n * @param {Object} data - the data to be added to the data layer\r\n */\r\nfunction buildDataLayerViewGeneral(data) {\r\n if (typeof utag_data !== 'undefined' && typeof utag !== 'undefined') {\r\n Object.keys(data).forEach(key => {\r\n utag_data[key] = data[key];\r\n });\r\n\r\n // load again the view data\r\n utag.track('view', utag_data);\r\n\r\n // replace variable in script\r\n // eslint-disable-next-line no-use-before-define\r\n replaceScript();\r\n }\r\n}\r\n\r\n/**\r\n * Removes the general data from the data layer and reloads the view data\r\n * @param {Object} data - the data to be removed from the data layer\r\n * @param {Array} except - the keys to be excluded from the removal\r\n * @returns {void}\r\n */\r\nfunction removeDataLayerViewGeneralData(data, except = []) {\r\n if (typeof utag_data !== 'undefined' && typeof utag !== 'undefined') {\r\n Object.keys(data).forEach(key => {\r\n if (except.indexOf(key) === -1) {\r\n delete utag_data[key];\r\n }\r\n });\r\n\r\n // load again the view data\r\n utag.track('view', utag_data);\r\n\r\n // replace variable in script\r\n // eslint-disable-next-line no-use-before-define\r\n replaceScript();\r\n }\r\n}\r\n\r\n/**\r\n * Replaces a script element with a new one that contains the `utag_data` variable.\r\n *\r\n * @function\r\n * @name replaceScript\r\n * @returns {void}\r\n *\r\n * @description\r\n * This function replaces a script element with a new one that contains the `utag_data` variable. The `utag_data` variable is a global variable that contains data for the Tealium tag management system.\r\n * This function assumes that there is an existing script element with the ID `js-data-layer-script` on the page. The `utag_data` variable must be defined and accessible in the global scope for this function to work properly.\r\n */\r\nfunction replaceScript() {\r\n if (typeof utag_data !== 'undefined') {\r\n // Get the script element to replace\r\n var scriptToReplace = document.getElementById('js-data-layer-script');\r\n if (scriptToReplace) {\r\n // Create a new script element\r\n var script = document.createElement('script');\r\n script.type = 'text/javascript';\r\n script.id = 'js-data-layer-script';\r\n // Create a text node with the utag_data variable\r\n var scriptContent = document.createTextNode('var utag_data = ' + JSON.stringify(utag_data, null, ' ') + ';');\r\n script.appendChild(scriptContent);\r\n // Replace the old script element with the new one\r\n scriptToReplace.parentNode.replaceChild(script, scriptToReplace);\r\n }\r\n }\r\n}\r\n\r\nmodule.exports = {\r\n methods: {\r\n buildDataLayerView: buildDataLayerView,\r\n buildDataLayerEventLinkCheckout: buildDataLayerEventLinkCheckout,\r\n buildDataLayerEventLink: buildDataLayerEventLink,\r\n getProductName: getProductName,\r\n buildDataLayerViewGeneral: buildDataLayerViewGeneral,\r\n getProductCategory: getProductCategory,\r\n getPageCategory: getPageCategory,\r\n getPageType: getPageType,\r\n getPageName: getPageName,\r\n getPageNameWithoutWebOrange: getPageNameWithoutWebOrange,\r\n removeDataLayerViewGeneralData: removeDataLayerViewGeneralData,\r\n addProductToDataLayer: addProductToDataLayer,\r\n isClient: isClient,\r\n replaceScript: replaceScript\r\n\r\n }\r\n};\r\n"],"sourceRoot":""}