/** * NOTICE OF LICENSE * This source file is subject to a trade license awarded by * Garamo Online S.L. * Any use, public communication, reproduction, modification or * distribution of this source file without the written consent of * Garamo Online S.L. It Is prohibited. * * @author ReactionCode * @copyright Garamo Online S.L. 2024. * @license Commercial license */(()=>{"use strict";class t{constructor(){}static getContext(){return t.instance||(t.instance=new t),t.instance}getTrackingConfig(){if(this.trackingConfig)return this.trackingConfig;throw Error("Unable to load Tracking Config Context")}setTrackingConfig(t){this.trackingConfig=t}getTrackingData(){return this.trackingData}setTrackingData(t){this.trackingData=t}getTrackingPlatform(){if(this.trackingPlatform)return this.trackingPlatform;throw Error("Unable to load Tracking Platform Context")}setTrackingPlatform(t){this.trackingPlatform=t}getSessionStorage(){if(this.sessionStorage)return this.sessionStorage;throw Error("Unable to load Session Storage Context")}setSessionStorage(t){this.sessionStorage=t}}class e{constructor(){this.hasSessionStorage="Storage"===Object.prototype.toString.call(sessionStorage).slice(8,-1)}getItem(t){let e=null;return this.hasSessionStorage&&(e=sessionStorage.getItem(t)),e}setItem(t,e){this.hasSessionStorage&&sessionStorage.setItem(t,e)}removeItem(t){this.hasSessionStorage&&sessionStorage.removeItem(t)}clearAll(){this.hasSessionStorage&&sessionStorage.clear()}}class i{constructor(t,e){this.sessionStorage=t,this.idLang=e,this.storageKey="RcProductList",this.storageValue={},this.initStorage()}initStorage(){const t=this.sessionStorage.getItem(this.storageKey);t&&(this.storageValue=JSON.parse(t))}addProduct(t){this.storageValue[t.id_index]=t,this.updateSessionStorageValue()}updateSessionStorageValue(){const t=JSON.stringify(this.storageValue);this.sessionStorage.setItem(this.storageKey,t)}getProduct(t){let e=null;const i=this.buildIndex(t);return Object.prototype.hasOwnProperty.call(this.storageValue,i)&&(e=this.storageValue[i]),e}buildIndex(t){return[t.idProduct,t.idProductAttribute,this.idLang].join("-")}}class r{constructor(t){this.storageKey="RcAttributionList",this.storageValue={},this.sessionStorage=t,this.initStorage()}initStorage(){const t=this.sessionStorage.getItem(this.storageKey);t&&(this.storageValue=JSON.parse(t))}addAttribution(t,e){this.storageValue[t]=e,this.updateSessionStorageValue()}updateSessionStorageValue(){const t=JSON.stringify(this.storageValue);this.sessionStorage.setItem(this.storageKey,t)}getAttributionList(){return this.storageValue}getAttribution(t){let e=null;return Object.prototype.hasOwnProperty.call(this.storageValue,t)&&(e=this.storageValue[t]),e}removeSessionStorageKey(){this.sessionStorage.removeItem(this.storageKey)}}class s{constructor(){this.trackingConfig=t.getContext().getTrackingConfig();const s=this.trackingConfig.context.localization.id_lang,n=new e;this.attributionStorage=new r(n),this.productStorage=new i(n,s)}initTrackingData(t){Object.prototype.hasOwnProperty.call(t,"detail_products_list")&&t.detail_products_list.length&&this.addProductsList(t.detail_products_list)}getProductModel(t){return this.productStorage.getProduct(t)}addProductsList(t){t.forEach((t=>this.productStorage.addProduct(t)))}addAttributionData(t,e){const i={productList:this.trackingConfig.context.page.controller_name,productPosition:e};this.attributionStorage.addAttribution(t,i)}getAttributionDataList(){return this.attributionStorage.getAttributionList()}}class n{static getTemplateData(t){const e=n.getRawTemplateData(t);return n.parseModuleData(e)}static getRawTemplateData(t){let e="";const i=document.querySelector(t);return i instanceof HTMLElement&&i.dataset.trackingData&&i.dataset.trackingData.length&&(e=i.dataset.trackingData),e}static parseModuleData(t){return JSON.parse(decodeURIComponent(t)||"{}")}}class a{constructor(){this.errorLog=[],this.context=t.getContext(),this.trackingConfig=n.getTemplateData(this.getTrackingConfigNode()),this.context.setTrackingConfig(this.trackingConfig),this.sessionStorage=new s,this.context.setSessionStorage(this.sessionStorage)}}class o{constructor(){this.actionTrackingEvents=[],this.dataTrackingEvents=[],this.trackingConfig=t.getContext().getTrackingConfig(),this.createPageEvents()}createPageEvents(){this.createAddToCartEvent(),this.createCartViewEvent(),this.createCategoryEvent(),this.createCheckoutEvent(),this.createCustomerLogin(),this.createCustomerSignUp(),this.createHomeEvent(),this.createOrderCompleteEvent(),this.createProductClickEvent(),this.createProductShareEvent(),this.createProductViewEvent(),this.createPromotionClickEvent(),this.createSearchEvent(),this.createViewItemsListEvent()}initPageEvents(){this.actionTrackingEvents.forEach((t=>t.initEvent()))}initDataEvents(t){t&&this.dataTrackingEvents.forEach((e=>e.initDataEvent(t)))}}class c{constructor(){this.trackingConfig=t.getContext().getTrackingConfig(),this.trackingPlatform=t.getContext().getTrackingPlatform()}}class d{constructor(t){this.requestConfig=t,this.errorMessage="Something went wrong on request",this.requestConfig=t,this.formData=this.buildFormData()}buildFormData(){const t=new FormData;return t.append("fc",this.requestConfig.fc),t.append("module",this.requestConfig.module),t.append("controller",this.requestConfig.controller),t.append("action",this.requestConfig.action),t.append("data",encodeURIComponent(JSON.stringify(this.requestConfig.data))),t.append("token",this.requestConfig.token),t}fetchRequest(){return t=this,e=void 0,r=function*(){const t={method:"POST",mode:"same-origin",body:this.formData},e=new Request(this.requestConfig.url,t),i=yield fetch(e);if(i.ok){const t=yield i.json();return Promise.resolve(t)}return Promise.reject(new Error(this.errorMessage))},new((i=void 0)||(i=Promise))((function(s,n){function a(t){try{c(r.next(t))}catch(t){n(t)}}function o(t){try{c(r.throw(t))}catch(t){n(t)}}function c(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,o)}c((r=r.apply(t,e||[])).next())}));var t,e,i,r}xhrRequest(){return new Promise(((t,e)=>{const i=new XMLHttpRequest;i.open("POST",this.requestConfig.url,!0),i.responseType="json",i.onload=()=>{200===i.status?t(i.response):e(new Error(this.errorMessage))},i.send(this.formData)}))}}var u=function(t,e,i,r){return new(i||(i=Promise))((function(s,n){function a(t){try{c(r.next(t))}catch(t){n(t)}}function o(t){try{c(r.throw(t))}catch(t){n(t)}}function c(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,o)}c((r=r.apply(t,e||[])).next())}))};class h{static getProductsDetailList(e){return u(this,void 0,void 0,(function*(){const i=t.getContext().getSessionStorage();let r=[];const s=[];if(e.forEach((t=>{const e=i.getProductModel(t);e?r.push(e):s.push(t)})),s.length){const t=yield h.fetchProductsLists(e);t.length&&i.addProductsList(t),r=[...r,...t]}return r}))}static fetchProductsLists(e){return u(this,void 0,void 0,(function*(){const i=t.getContext().getTrackingConfig(),r={url:i.context.shop.base_dir+"index.php",fc:"module",module:i.context.tracking_module.module_name,controller:"datarequest",action:"getProductsDetail",data:e,token:i.context.tracking_module.token};return new d(r).fetchRequest()}))}}class l extends c{constructor(){super(...arguments),this.cartProducts=[],this.productThemeDataList=[]}initEvent(){this.updateCartProducts(),prestashop.on("updateCart",this.triggerEvent.bind(this))}updateCartProducts(){var t,e;void 0===(null===(t=null===prestashop||void 0===prestashop?void 0:prestashop.cart)||void 0===t?void 0:t.products)&&"complete"!==document.readyState?window.addEventListener("load",this.updateCartProducts.bind(this),!1):this.cartProducts=(null===(e=null===prestashop||void 0===prestashop?void 0:prestashop.cart)||void 0===e?void 0:e.products)||[]}triggerEvent(t){return e=this,i=void 0,s=function*(){if(this.productThemeDataList=l.getProductsDataList(t),this.productThemeDataList.length){const t=yield h.getProductsDetailList(this.productThemeDataList),e=this.getQuantity();t.length&&e&&this.trackingPlatform.addToCart(t[0],e)}this.updateCartProducts()},new((r=void 0)||(r=Promise))((function(t,n){function a(t){try{c(s.next(t))}catch(t){n(t)}}function o(t){try{c(s.throw(t))}catch(t){n(t)}}function c(e){var i;e.done?t(e.value):(i=e.value,i instanceof r?i:new r((function(t){t(i)}))).then(a,o)}c((s=s.apply(e,i||[])).next())}));var e,i,r,s}static getProductsDataList(t){const e=[];return l.isValidResponse(t)&&e.push({idProduct:t.resp.id_product,idProductAttribute:t.resp.id_product_attribute}),e}static isValidResponse(t){return Object.prototype.hasOwnProperty.call(t,"resp")&&t.resp.success}getQuantity(){const t=this.cartProducts.filter(this.filterCartProducts.bind(this)),e=prestashop.cart.products.filter(this.filterCartProducts.bind(this));let i=0;return e.length&&(i=e[0].quantity,t.length&&(i-=t[0].quantity)),i}filterCartProducts(t){const e=this.productThemeDataList[0];return t.id_product.toString()===e.idProduct.toString()&&t.id_product_attribute.toString()===e.idProductAttribute.toString()}}class g{constructor(){this.trackingPlatform=t.getContext().getTrackingPlatform()}initDataEvent(t){Object.prototype.hasOwnProperty.call(t,"detail_products_list")&&Object.prototype.hasOwnProperty.call(t,"order_products_list")&&t.detail_products_list.length&&t.order_products_list.length&&this.trackingPlatform.cartView(t.detail_products_list,t.order_products_list)}}var p=function(t,e,i,r){return new(i||(i=Promise))((function(s,n){function a(t){try{c(r.next(t))}catch(t){n(t)}}function o(t){try{c(r.throw(t))}catch(t){n(t)}}function c(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,o)}c((r=r.apply(t,e||[])).next())}))};class m extends g{constructor(){super(...arguments),this.cartProductsQuantities={},this.lastInputFocus=""}initEvent(){document.addEventListener("click",this.handleEvent.bind(this),!0),prestashop.on("updateCart",this.updateQuantity.bind(this))}handleEvent(t){0===t.button&&t.target instanceof HTMLElement&&(t.target.closest(".js-increase-product-quantity")&&!m.isFocused(t.target)?this.increaseQuantity(t.target):t.target.closest(".js-decrease-product-quantity")&&!m.isFocused(t.target)?this.decreaseQuantity(t.target):t.target.closest(".js-cart-line-product-quantity")?this.setInputCurrentQuantity(t.target):t.target.closest(".remove-from-cart")&&this.removeFromCart(t.target))}static isFocused(t){const e=t.closest(".cart-item");if(e instanceof HTMLElement){const t=e.querySelector(".js-cart-line-product-quantity");return document.activeElement===t}return!1}increaseQuantity(t){return p(this,void 0,void 0,(function*(){const e=m.getProductsDataList(t);this.triggerEvent(e,1,this.trackingPlatform.addToCart.bind(this.trackingPlatform))}))}decreaseQuantity(t){return p(this,void 0,void 0,(function*(){const e=m.getProductsDataList(t);this.triggerEvent(e,1,this.trackingPlatform.removeFromCart.bind(this.trackingPlatform))}))}removeFromCart(t){const e=m.getProductsDataList(t),i=t.closest(".cart-item");if(i instanceof HTMLElement){const t=i.querySelector(".js-cart-line-product-quantity");if(t instanceof HTMLInputElement){const i=parseInt(t.value);this.triggerEvent(e,i,this.trackingPlatform.removeFromCart.bind(this.trackingPlatform))}}}static getProductsDataList(t){const e=t.closest(".cart-item"),i=[];let r,s;if(e instanceof HTMLElement){const t=e.querySelector(".remove-from-cart");t instanceof HTMLElement&&(r=parseInt(t.dataset.idProduct||"0"),s=parseInt(t.dataset.idProductAttribute||"0"),r&&i.push({idProduct:r,idProductAttribute:s}))}return i}setInputCurrentQuantity(t){return p(this,void 0,void 0,(function*(){const e=m.getProductsDataList(t),i=e[0],r=t.closest(".js-cart-line-product-quantity");if(e.length&&r instanceof HTMLInputElement){const t=JSON.stringify(i);t!==this.lastInputFocus&&(this.cartProductsQuantities[t]=parseInt(r.value),this.lastInputFocus=t)}}))}updateQuantity(t){return p(this,void 0,void 0,(function*(){if(t.reason.success){const e={idProduct:t.reason.id_product,idProductAttribute:t.reason.id_product_attribute},i=[e];if(i.length){const r=JSON.stringify(e),s=t.reason.quantity;if(this.lastInputFocus="",s>this.cartProductsQuantities[r]){const t=s-this.cartProductsQuantities[r];this.triggerEvent(i,t,this.trackingPlatform.addToCart.bind(this.trackingPlatform))}else{const t=this.cartProductsQuantities[r]-s;this.triggerEvent(i,t,this.trackingPlatform.removeFromCart.bind(this.trackingPlatform))}}}}))}triggerEvent(t,e,i){return p(this,void 0,void 0,(function*(){if(t.length){const r=yield h.getProductsDetailList(t);r.length&&e&&i(r[0],e)}}))}initDataEvent(t){Object.prototype.hasOwnProperty.call(t,"detail_products_list")&&Object.prototype.hasOwnProperty.call(t,"order_products_list")&&t.detail_products_list.length&&t.order_products_list.length&&this.trackingPlatform.cartView(t.detail_products_list,t.order_products_list)}}class v{constructor(){this.trackingConfig=t.getContext().getTrackingConfig(),this.trackingPlatform=t.getContext().getTrackingPlatform()}initEvent(){this.triggerEvent()}triggerEvent(){this.hasCategoryData()&&this.trackingPlatform.categoryPageView()}hasCategoryData(){return Object.prototype.hasOwnProperty.call(this.trackingConfig.context.page,"category")&&Object.prototype.hasOwnProperty.call(this.trackingConfig.context.page.category,"id_category")&&Object.prototype.hasOwnProperty.call(this.trackingConfig.context.page.category,"name")&&Object.prototype.hasOwnProperty.call(this.trackingConfig.context.page.category,"path")}}class y extends v{}class f{constructor(){this.trackingConfig=t.getContext().getTrackingConfig(),this.checkoutController=this.getCheckoutModule()}initEvent(){this.isValidCheckoutController()&&this.checkoutController.initEvent()}isValidCheckoutController(){return this.trackingConfig.context.page.controller_name===this.trackingConfig.context.tracking_module.checkout_module.controller}initDataEvent(t){this.isValidCheckoutController()&&f.isValidTrackingData(t)&&this.checkoutController.initDataEvent(t)}static isValidTrackingData(t){return Object.prototype.hasOwnProperty.call(t,"detail_products_list")&&Object.prototype.hasOwnProperty.call(t,"order_products_list")&&Boolean(t.detail_products_list.length)&&Boolean(t.order_products_list.length)}}class k{constructor(e){this.checkoutTrait=e,this.step=1,this.carrierSelected="",this.paymentSelected="",this.trackingPlatform=t.getContext().getTrackingPlatform()}initCheckoutEvent(){this.setDefaultCheckoutValues(),document.addEventListener("click",this.delegateCheckoutEvent.bind(this),!0)}static isValidMouseEvent(t){return 0===t.button&&t.isTrusted}static isValidAgreement(t="input[name=cgv]"){const e=document.querySelector(t);return!(e instanceof HTMLInputElement)||e.checked}static isCheckoutWithCarrier(t){return Boolean(document.querySelector(t))}sendTrackingCarrierOption(){this.checkoutTrait.getCartProductsData().then((t=>{t&&(this.detailProductsList=t[0],this.orderProductsList=t[1]),this.trackingPlatform.checkoutOption("shipping",this.carrierSelected,this.step,this.detailProductsList,this.orderProductsList)}))}sendTrackingPaymentOption(){this.checkoutTrait.getCartProductsData().then((t=>{t&&(this.detailProductsList=t[0],this.orderProductsList=t[1]),this.trackingPlatform.checkoutOption("payment",this.paymentSelected,this.step,this.detailProductsList,this.orderProductsList)}))}initDataEvent(t){this.detailProductsList=t.detail_products_list,this.orderProductsList=t.order_products_list,this.trackingPlatform.checkoutProgress(t.detail_products_list,t.order_products_list,this.step)}}class P extends k{initEvent(){this.setCurrentStep(),this.initCheckoutEvent()}setCurrentStep(){const t=document.querySelectorAll(".checkout-step"),e=Array.prototype.findIndex.call(t,(t=>t.classList.contains("js-current-step")));this.step=-1!==e?e:1}setDefaultCheckoutValues(){this.getCarrierSelected()}delegateCheckoutEvent(t){if(P.isValidMouseEvent(t)){const e=t.target;P.isValidCarrierSelectionEvent(e)?this.getCarrierSelected():P.isValidCarrierEvent(e)?this.sendTrackingCarrierOption():P.isValidPaymentSelectionEvent(e)?this.getPaymentSelected():P.isValidPurchaseEvent(e)&&this.sendTrackingPaymentOption()}}static isValidCarrierSelectionEvent(t){return t.matches("#checkout-delivery-step .delivery-options *")}getCarrierSelected(){let t="",e=document.querySelector("[id^=delivery_option_]:checked");e=e?e.closest(".delivery-option"):null,e=e?e.querySelector(".carrier-name"):null,e&&(t=e.textContent||""),this.carrierSelected=t.trim()}static isValidCarrierEvent(t){return Boolean(t.closest("#checkout-delivery-step button[type=submit]"))}static isValidPaymentSelectionEvent(t){return t.matches("#checkout-payment-step .payment-options *")}getPaymentSelected(){let t="";const e=document.querySelector("[id^=payment-option-]:checked");e&&Object.hasOwnProperty.call(e.dataset,"moduleName")&&(t=e.dataset.moduleName||""),this.paymentSelected=t.trim()}static isValidPurchaseEvent(t){return Boolean(t.closest("#payment-confirmation button[type=submit]"))&&P.isValidAgreement()}static isValidAgreement(){const t=document.querySelector("input[name^=conditions_to_approve]");return!(t instanceof HTMLInputElement)||t.checked}initDataEvent(t){0!==this.step&&super.initDataEvent(t)}}class C extends k{setDefaultCheckoutValues(){this.getCarrierSelected(),this.getPaymentSelected()}static isValidCarrierSelectionEvent(t){return t.matches("#pwc-delivery-options *")}getPaymentSelected(){this.paymentSelected="sveacheckout"}static isValidPurchaseEvent(t){return t.matches("a *")}triggerPurchaseEvent(){this.sendTrackingCarrierOption(),this.sendTrackingPaymentOption()}}class E extends C{constructor(t){super(t),this.cartViewEvent=new m}initEvent(){this.cartViewEvent.initEvent(),this.initCheckoutEvent()}delegateCheckoutEvent(t){if(E.isValidMouseEvent(t)){const e=t.target;E.isValidCarrierSelectionEvent(e)?this.getCarrierSelected():E.isValidPurchaseEvent(e)&&this.triggerPurchaseEvent()}}getCarrierSelected(){let t="";const e=document.querySelector(".selected[id^=delivery_option] .flex-grow-1.flex-shrink-1");return e instanceof HTMLElement&&e.firstElementChild instanceof HTMLElement&&(t=e.firstElementChild.innerText.trim().toLowerCase()),this.carrierSelected=t}}class w extends k{setDefaultCheckoutValues(){this.getCarrierSelected(),this.getPaymentSelected()}static isValidCarrierSelectionEvent(t){return t.matches("#klarnacarrier *")}getPaymentSelected(){this.paymentSelected="klarna"}triggerPurchaseEvent(){this.sendTrackingCarrierOption(),this.sendTrackingPaymentOption()}static isValidPurchaseEvent(t){return t.matches("a *")}}class _ extends w{constructor(t){super(t),this.cartViewEvent=new m}initEvent(){this.cartViewEvent.initEvent(),this.initCheckoutEvent()}delegateCheckoutEvent(t){if(_.isValidMouseEvent(t)){const e=t.target;_.isValidCarrierSelectionEvent(e)?this.getCarrierSelected():_.isValidPurchaseEvent(e)&&this.triggerPurchaseEvent()}}getCarrierSelected(){let t="";const e=document.querySelector("#klarnacarrier .selected .kco-sel-list__item__title");e instanceof HTMLElement&&e.firstElementChild instanceof HTMLElement&&(t=e.firstElementChild.innerText.trim().toLowerCase()),this.carrierSelected=t}}class L extends k{delegateCheckoutEvent(t){}setDefaultCheckoutValues(){this.getCarrierSelected(),this.getPaymentSelected()}getCarrierSelected(){this.carrierSelected="not detected"}getPaymentSelected(){this.paymentSelected="qliro"}}class S extends L{constructor(t){super(t),this.cartViewEvent=new m}initEvent(){this.cartViewEvent.initEvent()}}class b extends k{setDefaultCheckoutValues(){setTimeout(this.getCheckoutLazyOptions.bind(this),1e3)}getCheckoutLazyOptions(){document.querySelector("#thecheckout-payment")?(this.getCarrierSelected(),this.getPaymentSelected()):setTimeout(this.getCheckoutLazyOptions.bind(this),1e3)}}class T extends b{constructor(t){super(t),this.cartViewEvent=new m}initEvent(){this.cartViewEvent.initEvent(),this.initCheckoutEvent()}delegateCheckoutEvent(t){if(T.isValidMouseEvent(t)){const e=t.target;e.matches("[id^=tc-container] *")&&(T.isValidCarrierSelectionEvent(e)?this.getCarrierSelected():T.isValidPaymentSelectionEvent(e)?this.getPaymentSelected():T.isValidPurchaseEvent(e)&&this.triggerPurchaseEvent())}}static isValidCarrierSelectionEvent(t){return t.matches("#thecheckout-shipping *")}getCarrierSelected(){let t="";const e=document.querySelector(".delivery-options input:checked");if(e instanceof HTMLInputElement){const i=e.closest(".delivery-option-row");if(i instanceof HTMLElement){const e=i.querySelector(".carrier-name");t=e instanceof HTMLElement?e.innerText:""}}this.carrierSelected=t.trim().toLowerCase()}static isValidPaymentSelectionEvent(t){return t.matches("#thecheckout-payment *")}getPaymentSelected(){let t="";const e=document.querySelector(".payment-options input:checked");e instanceof HTMLInputElement&&(t=e.dataset.moduleName||""),this.paymentSelected=t.trim().toLowerCase()}static isValidPurchaseEvent(t){return Boolean(t.closest("#confirm_order"))&&T.isValidAgreement()}static isValidAgreement(){const t=document.querySelector("input[name^=conditions_to_approve]");return!(t instanceof HTMLInputElement)||t.checked}triggerPurchaseEvent(){T.isCheckoutWithCarrier("body:not(.is-virtual-cart) #thecheckout-shipping")&&this.sendTrackingCarrierOption(),this.sendTrackingPaymentOption()}}class x extends k{static isCartViewEvent(){return Boolean(document.querySelector("#cart_summary"))}setDefaultCheckoutValues(){setTimeout(this.getCheckoutLazyOptions.bind(this),1e3)}getCheckoutLazyOptions(){document.querySelector("#payment_method_container")?(this.getCarrierSelected(),this.getPaymentSelected()):setTimeout(this.getCheckoutLazyOptions.bind(this),1e3)}static isValidPaymentSelectionEvent(t){return t.matches("#payment_method_container *")}static isValidPurchaseEvent(t,e){return Boolean(t.closest("#btn_place_order, #btn-placer_order"))&&k.isValidAgreement(e)}}class V extends x{constructor(t){super(t),this.cartViewEvent=new m}initEvent(){V.isCartViewEvent()?this.cartViewEvent.initEvent():this.initCheckoutEvent()}delegateCheckoutEvent(t){if(V.isValidMouseEvent(t)){const e=t.target;e.matches("#onepagecheckoutps_contenedor *, #opc_main *")&&(V.isValidCarrierSelectionEvent(e)?this.getCarrierSelected():V.isValidPaymentSelectionEvent(e)?this.getPaymentSelected():V.isValidPurchaseEvent(e,"input[name=conditions_to_approve]")&&this.triggerPurchaseEvent())}}static isValidCarrierSelectionEvent(t){return t.matches("#js-delivery *, #form-shipping_container .delivery-options *")}getCarrierSelected(){let t="";const e=document.querySelector("[name^=delivery_option]:checked");if(e instanceof HTMLInputElement){const i=e.closest(".delivery-option");if(i instanceof HTMLElement){const e=i.querySelector(".delivery_option_title");t=e instanceof HTMLElement&&e.textContent?e.textContent:""}}this.carrierSelected=t.trim().toLowerCase()}getPaymentSelected(){let t="";const e=document.querySelector("[name=payment-option]:checked");e instanceof HTMLInputElement&&(t=e.value.trim().toLowerCase()),this.paymentSelected=t}triggerPurchaseEvent(){V.isCheckoutWithCarrier("#onepagecheckoutps_contenedor #js-delivery, #opc_main #form-shipping_container")&&this.sendTrackingCarrierOption(),this.sendTrackingPaymentOption()}initDataEvent(t){V.isCartViewEvent()?this.cartViewEvent.initDataEvent(t):super.initDataEvent(t)}}class O extends k{setDefaultCheckoutValues(){setTimeout(this.getCheckoutLazyOptions.bind(this),1e3)}getCheckoutLazyOptions(){document.querySelector("#st-checkout-payment-step")?(this.getCarrierSelected(),this.getPaymentSelected()):setTimeout(this.getCheckoutLazyOptions.bind(this),1e3)}}class D extends O{constructor(t){super(t),this.cartViewEvent=new m}initEvent(){this.cartViewEvent.initEvent(),this.initCheckoutEvent()}delegateCheckoutEvent(t){if(D.isValidMouseEvent(t)){const e=t.target;e.matches("#content.steco_container *")&&(D.isValidCarrierSelectionEvent(e)?this.getCarrierSelected():D.isValidPaymentSelectionEvent(e)?this.getPaymentSelected():D.isValidPurchaseEvent(e)&&this.triggerPurchaseEvent())}}static isValidCarrierSelectionEvent(t){return t.matches("#st-checkout-delivery-step *")}getCarrierSelected(){let t="";const e=document.querySelector(".delivery-options input:checked");if(e instanceof HTMLInputElement){const i=e.closest(".delivery-option");if(i instanceof HTMLElement){const e=i.querySelector(".carrier-name");t=e instanceof HTMLElement?e.innerText:""}}this.carrierSelected=t.trim().toLowerCase()}static isValidPaymentSelectionEvent(t){return t.matches("#st-checkout-payment-step *")}getPaymentSelected(){let t="";const e=document.querySelector(".payment-options input:checked");e instanceof HTMLInputElement&&(t=e.dataset.moduleName||""),this.paymentSelected=t.trim().toLowerCase()}static isValidPurchaseEvent(t){return Boolean(t.closest("#payment-confirmation"))&&D.isValidAgreement()}static isValidAgreement(){const t=document.querySelector("input[name^=conditions_to_approve]");return!(t instanceof HTMLInputElement)||t.checked}triggerPurchaseEvent(){D.isCheckoutWithCarrier("#st-checkout-delivery-step")&&this.sendTrackingCarrierOption(),this.sendTrackingPaymentOption()}}class j extends k{setDefaultCheckoutValues(){setTimeout(this.getCheckoutLazyOptions.bind(this),1e3)}getCheckoutLazyOptions(){document.querySelector("#supercheckout-fieldset")?(this.getCarrierSelected(),this.getPaymentSelected()):setTimeout(this.getCheckoutLazyOptions.bind(this),1e3)}}class I extends j{constructor(t){super(t),this.cartViewEvent=new m}initEvent(){this.cartViewEvent.initEvent(),this.initCheckoutEvent()}delegateCheckoutEvent(t){if(I.isValidMouseEvent(t)){const e=t.target;e.matches("#supercheckout-fieldset *")&&(I.isValidCarrierSelectionEvent(e)?this.getCarrierSelected():I.isValidPaymentSelectionEvent(e)?this.getPaymentSelected():I.isValidPurchaseEvent(e)&&this.triggerPurchaseEvent())}}static isValidCarrierSelectionEvent(t){return t.matches("#shipping-method *")}getCarrierSelected(){let t="";const e=document.querySelector("input.supercheckout_shipping_option:checked");if(e instanceof HTMLInputElement){const i=e.closest("li");if(i instanceof HTMLElement){const e=i.querySelector("img")||i.querySelector("label");e instanceof HTMLImageElement?t=e.alt:e instanceof HTMLLabelElement&&e.firstChild instanceof Text&&e.firstChild.textContent&&(t=e.firstChild.textContent)}}this.carrierSelected=t.trim().toLowerCase()}static isValidPaymentSelectionEvent(t){return t.matches("#payment-method *")}getPaymentSelected(){let t="";const e=document.querySelector(".payment-options input:checked");e instanceof HTMLInputElement&&(t=e.dataset.moduleName||""),this.paymentSelected=t.trim().toLowerCase()}static isValidPurchaseEvent(t){return Boolean(t.closest("#supercheckout_confirm_order"))&&I.isValidAgreement()}static isValidAgreement(){const t=document.querySelector("input[name^=conditions_to_approve]");return!(t instanceof HTMLInputElement)||t.checked}triggerPurchaseEvent(){I.isCheckoutWithCarrier("input.supercheckout_shipping_option")&&this.sendTrackingCarrierOption(),this.sendTrackingPaymentOption()}}class M{constructor(){this.productsThemeData=[],this.detailProductsList=[],this.orderProductsList=[]}}var q=function(t,e,i,r){return new(i||(i=Promise))((function(s,n){function a(t){try{c(r.next(t))}catch(t){n(t)}}function o(t){try{c(r.throw(t))}catch(t){n(t)}}function c(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,o)}c((r=r.apply(t,e||[])).next())}))};class A extends M{getCartProductsData(){return q(this,void 0,void 0,(function*(){return this.updateCartProducts(),this.getProductsThemeData(),yield this.getProductsListData(),this.detailProductsList&&this.getOrderProductsList(),[this.detailProductsList,this.orderProductsList]}))}updateCartProducts(){this.cartProducts=prestashop.cart.products}getProductsThemeData(){this.cartProducts&&this.cartProducts.forEach((t=>{this.productsThemeData.push({idProduct:parseInt(t.id_product),idProductAttribute:parseInt(t.id_product_attribute)})}))}getProductsListData(){return q(this,void 0,void 0,(function*(){this.productsThemeData.length&&(this.detailProductsList=yield h.getProductsDetailList(this.productsThemeData))}))}getOrderProductsList(){this.detailProductsList&&this.cartProducts&&(this.orderProductsList=JSON.parse(JSON.stringify(this.detailProductsList)),this.cartProducts.forEach(((t,e)=>{this.orderProductsList[e].quantity=t.quantity})))}}class H{static getCheckoutController(){let e;const i=new A;switch(t.getContext().getTrackingConfig().context.tracking_module.checkout_module.module){case"klarnaofficial":e=new _(i);break;case"onepagecheckoutps":e=new V(i);break;case"pw_qlirocheckout":e=new S(i);break;case"steasycheckout":e=new D(i);break;case"supercheckout":e=new I(i);break;case"sveacheckout":e=new E(i);break;case"thecheckout":e=new T(i);break;default:e=new P(i)}return e}}class N extends f{getCheckoutModule(){return H.getCheckoutController()}}class Q{constructor(){this.trackingConfig=t.getContext().getTrackingConfig(),this.trackingPlatform=t.getContext().getTrackingPlatform()}initEvent(){this.triggerEvent()}triggerEvent(){this.trackingConfig.context.user&&this.trackingConfig.context.user.is_new_login&&this.trackingPlatform.customerLogin()}}class R extends Q{}class F{constructor(){this.trackingConfig=t.getContext().getTrackingConfig(),this.trackingPlatform=t.getContext().getTrackingPlatform()}initEvent(){this.triggerEvent()}triggerEvent(){this.trackingConfig.context.user&&this.trackingConfig.context.user.is_new_account&&this.trackingPlatform.customerSignUp()}}class B extends F{}class J{constructor(){this.trackingConfig=t.getContext().getTrackingConfig(),this.trackingPlatform=t.getContext().getTrackingPlatform()}initEvent(){"index"===this.trackingConfig.context.page.controller_name&&this.triggerEvent()}triggerEvent(){this.trackingPlatform.homePageView()}}class U extends J{}class z{constructor(){this.trackingConfig=t.getContext().getTrackingConfig(),this.trackingPlatform=t.getContext().getTrackingPlatform()}initDataEvent(t){z.isValidTrackingData(t)&&(this.trackingPlatform.isAvailable()?this.trackingPlatform.orderComplete(t.order_complete_data,t.detail_products_list,t.order_products_list,t.order_context_user_data,this.setOrderTrackingStatus.bind(this)):this.handleAdBlockOrderAborted(t.order_complete_data))}static isValidTrackingData(t){return Object.prototype.hasOwnProperty.call(t,"order_complete_data")&&Object.prototype.hasOwnProperty.call(t,"detail_products_list")&&Object.prototype.hasOwnProperty.call(t,"order_products_list")&&Object.prototype.hasOwnProperty.call(t,"order_context_user_data")&&Boolean(Object.keys(t.order_complete_data).length)&&Boolean(Object.keys(t.detail_products_list).length)&&Boolean(Object.keys(t.order_products_list).length)&&Boolean(Object.keys(t.order_context_user_data).length)}setOrderTrackingStatus(t){this.serverRequest("setOrderTrackingStatus",t)}handleAdBlockOrderAborted(t){this.serverRequest("handleAdBlockOrderAborted",t)}serverRequest(t,e){const i={url:this.trackingConfig.context.shop.base_dir+"index.php",fc:"module",module:this.trackingConfig.context.tracking_module.module_name,controller:"datarequest",action:t,data:e,token:this.trackingConfig.context.tracking_module.token};new d(i).fetchRequest()}}class K extends z{}class W{constructor(){this.trackingPlatform=t.getContext().getTrackingPlatform(),this.sessionStorage=t.getContext().getSessionStorage()}initEvent(){document.addEventListener("click",this.handleEvent.bind(this),!0)}triggerEvent(t){return e=this,i=void 0,s=function*(){if(t.length){const e=yield h.getProductsDetailList(t);if(e.length){const t=this.sessionStorage.getAttributionDataList();this.trackingPlatform.productClick(e[0],t)}}},new((r=void 0)||(r=Promise))((function(t,n){function a(t){try{c(s.next(t))}catch(t){n(t)}}function o(t){try{c(s.throw(t))}catch(t){n(t)}}function c(e){var i;e.done?t(e.value):(i=e.value,i instanceof r?i:new r((function(t){t(i)}))).then(a,o)}c((s=s.apply(e,i||[])).next())}));var e,i,r,s}}class G extends W{handleEvent(t){if(0===t.button&&t.target instanceof Element){const e=G.getProductThemeDataList(t.target);this.triggerEvent(e)}}static getProductThemeDataList(t){const e=[],i=t.closest(".js-product-miniature a");if(i instanceof HTMLElement){const r=".js-product-miniature",s=t.closest(r);if(s instanceof HTMLElement){const t=parseInt(s.dataset.idProduct||"0"),r=parseInt(i.dataset.idProductAttribute||s.dataset.idProductAttribute||"0");t&&e.push({idProduct:t,idProductAttribute:r})}}return e}}class ${constructor(){this.trackingConfig=t.getContext().getTrackingConfig(),this.trackingPlatform=t.getContext().getTrackingPlatform()}initEvent(){document.addEventListener("click",this.handleEvent.bind(this),!1)}triggerEvent(t,e){return i=this,r=void 0,n=function*(){if(t.length&&e){const i=yield h.getProductsDetailList(t);i.length&&this.trackingPlatform.productShare(i[0],e)}},new((s=void 0)||(s=Promise))((function(t,e){function a(t){try{c(n.next(t))}catch(t){e(t)}}function o(t){try{c(n.throw(t))}catch(t){e(t)}}function c(e){var i;e.done?t(e.value):(i=e.value,i instanceof s?i:new s((function(t){t(i)}))).then(a,o)}c((n=n.apply(i,r||[])).next())}));var i,r,s,n}static getSocialNetwork(t){return t.dataset.network||t.dataset.type||t.title||""}}class X extends ${constructor(){super(...arguments),this.productView={idProduct:0,idProductAttribute:0},this.productQuickView={idProduct:0,idProductAttribute:0}}initEvent(){super.initEvent(),prestashop.on("clickQuickView",this.handlePSEvent.bind(this)),prestashop.on("updatedProduct",this.handlePSEvent.bind(this))}handlePSEvent(t){X.isEventQuickView(t)?(this.productQuickView.idProduct=t.dataset.idProduct,this.productQuickView.idProductAttribute=t.dataset.idProductAttribute):this.productView.idProductAttribute=parseInt(t.id_product_attribute)}static isEventQuickView(t){return Object.prototype.hasOwnProperty.call(t,"dataset")}handleEvent(t){if(0===t.button&&t.target instanceof Element){const e=".js-social-sharing",i=t.target.closest(e);if(i instanceof HTMLElement){const t=this.getProductsDataList(i),e=X.getSocialNetwork(i);this.triggerEvent(t,e)}}}getProductsDataList(t){const e=[],i=t.closest("[id^=quickview-modal-]")instanceof HTMLElement?this.productQuickView:this.productView;return i.idProduct&&e.push(i),e}initDataEvent(t){"product"===this.trackingConfig.context.page.controller_name&&Object.prototype.hasOwnProperty.call(t,"detail_product_view")&&t.detail_product_view.length&&(this.productView.idProduct=t.detail_product_view[0].id_product,this.productView.idProductAttribute=t.detail_product_view[0].id_attribute)}}class Y{constructor(){this.trackingPlatform=t.getContext().getTrackingPlatform(),this.sessionStorage=t.getContext().getSessionStorage()}}class Z extends Y{constructor(){super(...arguments),this.latestProductView="",this.productView={idProduct:0,idProductAttribute:0},this.productQuickView={idProduct:0,idProductAttribute:0}}initEvent(){prestashop.on("clickQuickView",this.triggerEvent.bind(this)),prestashop.on("updatedProduct",this.triggerEvent.bind(this))}triggerEvent(t){return e=this,i=void 0,s=function*(){const e=this.getProductsDataList(t);if(e.length){const t=yield h.getProductsDetailList(e);t.length&&this.trackingPlatform.productView(t[0])}},new((r=void 0)||(r=Promise))((function(t,n){function a(t){try{c(s.next(t))}catch(t){n(t)}}function o(t){try{c(s.throw(t))}catch(t){n(t)}}function c(e){var i;e.done?t(e.value):(i=e.value,i instanceof r?i:new r((function(t){t(i)}))).then(a,o)}c((s=s.apply(e,i||[])).next())}));var e,i,r,s}getProductsDataList(t){const e=[];if(Z.isEventQuickView(t))this.productQuickView.idProduct=t.dataset.idProduct,this.productQuickView.idProductAttribute=t.dataset.idProductAttribute,e.push(this.productQuickView);else{const i=Z.isQuickViewModal()?this.productQuickView:this.productView;i.idProductAttribute=parseInt(t.id_product_attribute),this.isLatestProductView(i)&&(e.push(i),this.setLatestProductView(i))}return e}static isEventQuickView(t){return Object.prototype.hasOwnProperty.call(t,"dataset")}static isQuickViewModal(){return Boolean(document.querySelector("[id^=quickview]"))}isLatestProductView(t){return this.latestProductView!==JSON.stringify(t)}setLatestProductView(t){this.latestProductView=JSON.stringify(t)}initDataEvent(t){if(Object.prototype.hasOwnProperty.call(t,"detail_product_view")&&t.detail_product_view.length){this.sessionStorage.addProductsList(t.detail_product_view);const e=t.detail_product_view[0];this.productView.idProduct=e.id_product,this.productView.idProductAttribute=e.id_attribute,this.trackingPlatform.productView(e),this.setLatestProductView(this.productView)}}}var tt=function(t,e,i,r){return new(i||(i=Promise))((function(s,n){function a(t){try{c(r.next(t))}catch(t){n(t)}}function o(t){try{c(r.throw(t))}catch(t){n(t)}}function c(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,o)}c((r=r.apply(t,e||[])).next())}))};class et{static getThemeParameters(t){const e={pid:"",pnm:"",cnm:"",csl:"",ppid:"",ppaid:""};if(t.search){const i=new URLSearchParams(t.search);if(et.hasRequiredPromotionParams(i))return Object.keys(e).forEach((t=>{const r=i.get(t);r&&(e[t]=r)})),e}}static hasRequiredPromotionParams(t){return Boolean(t.get("pid"))}static getDetailPromotionModel(t){return tt(this,void 0,void 0,(function*(){const e={promotion_url:"",promotion_params:{promotion_id:"",promotion_name:"",creative_slot:"",creative_name:""}};if(t&&t.parameters&&(e.promotion_url=t.url,Object.entries({pid:"promotion_id",pnm:"promotion_name",cnm:"creative_name",csl:"creative_slot"}).forEach((([i,r])=>{var s;e.promotion_params[r]=(null===(s=t.parameters)||void 0===s?void 0:s[i])||""})),et.hasPromotionItem(t.parameters))){const i=yield et.getPromotionItem(t);i&&(e.promotion_item=i[0])}return e}))}static hasPromotionItem(t){return Boolean(t.ppid)}static getPromotionItem(t){var e,i;return tt(this,void 0,void 0,(function*(){const r={idProduct:parseInt(null===(e=t.parameters)||void 0===e?void 0:e.ppid),idProductAttribute:parseInt((null===(i=t.parameters)||void 0===i?void 0:i.ppaid)||"0")};return h.getProductsDetailList([r])}))}}var it=function(t,e,i,r){return new(i||(i=Promise))((function(s,n){function a(t){try{c(r.next(t))}catch(t){n(t)}}function o(t){try{c(r.throw(t))}catch(t){n(t)}}function c(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,o)}c((r=r.apply(t,e||[])).next())}))};class rt{constructor(){this.trackingPlatform=t.getContext().getTrackingPlatform()}initEvent(){document.addEventListener("click",this.triggerEvent.bind(this),!0)}triggerEvent(t){return it(this,void 0,void 0,(function*(){const e=yield this.getPromotionData(t);e&&this.trackingPlatform.promotionClick(e)}))}getPromotionData(t){return it(this,void 0,void 0,(function*(){let e;if(0===t.button&&t.target instanceof Element){const i=t.target.closest(".js-track-promo a");if(i){const t={url:i.href,parameters:et.getThemeParameters(i)};e=yield et.getDetailPromotionModel(t)}}return e}))}}class st extends rt{}class nt{constructor(){this.trackingConfig=t.getContext().getTrackingConfig(),this.trackingPlatform=t.getContext().getTrackingPlatform()}initEvent(){var t;(null===(t=this.trackingConfig.context.page.search_term)||void 0===t?void 0:t.length)&&this.trackingPlatform.searchPageView()}}class at extends nt{}class ot{constructor(){this.scrollTimeout=0,this.trackingConfig=t.getContext().getTrackingConfig(),this.trackingPlatform=t.getContext().getTrackingPlatform(),this.allItemsList=this.getAllItemsList()}initEvent(){window.addEventListener("scroll",this.triggerEvent.bind(this),!0),this.parseItemsList(),this.sendItems()}triggerEvent(){window.clearTimeout(this.scrollTimeout),this.parseItemsList(),this.scrollTimeout=window.setTimeout((()=>this.sendItems()),800)}parseItemsList(){this.allItemsList.length&&this.allItemsList.forEach((t=>{const e=t.getItemsListDetected();e.length&&e.forEach((e=>{ot.isElementInViewport(e)&&t.addItem(e)}))}))}static isElementInViewport(t){let e=!1;const i=window.innerHeight,r=window.scrollY,s=r,n=r+i;let a,o,c,d,u;const h=t.clientHeight;return h&&(c=getComputedStyle(t),d=parseInt(c.paddingTop)+parseInt(c.paddingBottom),u=t.getBoundingClientRect(),a=u.top+r,o=a+(h-d),e=a>=s&&a=s&&o{t.sendItems()})),window.clearTimeout(this.scrollTimeout)}}class ct{constructor(e){this.itemSelector=e,this.sendProducts=new Set,this.sentProducts=new Set,this.productsPosition={},this.trackingConfig=t.getContext().getTrackingConfig(),this.trackingPlatform=t.getContext().getTrackingPlatform(),this.sessionStorage=t.getContext().getSessionStorage()}getItemsListDetected(){return document.querySelectorAll(this.itemSelector)}addItem(t){const e=parseInt(t.getAttribute("data-id-product")||"0"),i=parseInt(t.getAttribute("data-id-product-attribute")||"0");if(e){const t={idProduct:e,idProductAttribute:i},r=JSON.stringify(t);this.sentProducts.has(r)||this.sendProducts.has(r)||this.sendProducts.add(r)}}sendItems(){return t=this,e=void 0,r=function*(){if(this.sendProducts.size){this.buildProductPositions();const t=this.getProductsDataListFromSendProducts(),e=yield h.getProductsDetailList(t);e.length&&(this.trackingPlatform.productsList(e,this.productsPosition),this.sentProducts=new Set([...Array.from(this.sentProducts),...Array.from(this.sendProducts)]),this.sendProducts.clear())}},new((i=void 0)||(i=Promise))((function(s,n){function a(t){try{c(r.next(t))}catch(t){n(t)}}function o(t){try{c(r.throw(t))}catch(t){n(t)}}function c(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,o)}c((r=r.apply(t,e||[])).next())}));var t,e,i,r}getProductsDataListFromSendProducts(){const t=[];return this.sendProducts.forEach((e=>{t.push(JSON.parse(e))})),t}buildProductPositions(){const t=this.getItemsListDetected();let e,i,r=this.getPageFirstPosition();t.forEach((t=>{if(e=parseInt(t.getAttribute("data-id-product")||"0"),i=parseInt(t.getAttribute("data-id-product-attribute")||"0"),e){const t={idProduct:e,idProductAttribute:i},s=JSON.stringify(t);Object.prototype.hasOwnProperty.call(this.productsPosition,s)||(this.productsPosition[s]=r,r+=1),this.sessionStorage.addAttributionData(s,this.productsPosition[s])}}))}}class dt extends ct{constructor(){super(".js-product-miniature")}getPageFirstPosition(){let t=1;const e=this.trackingConfig.context.page.products_per_page,i=new URLSearchParams(window.location.search).get("page");return i&&(t=parseInt(i)),e*t-e+1}}class ut{constructor(){this.itemSelector=".js-track-promo",this.sendPromotions=new Set,this.sentPromotions=new Set,this.trackingPlatform=t.getContext().getTrackingPlatform()}getItemsListDetected(){return document.querySelectorAll(this.itemSelector)}addItem(t){const e=t.querySelector("a");if(e){const t={url:e.href,parameters:et.getThemeParameters(e)};if(t.parameters){const e=JSON.stringify(t);this.sendPromotions.has(e)||this.sentPromotions.has(e)||this.sendPromotions.add(e)}}}sendItems(){return t=this,e=void 0,r=function*(){if(this.sendPromotions.size){const t=[];for(const e of this.sendPromotions){const i=JSON.parse(e),r=yield et.getDetailPromotionModel(i);r&&t.push(r)}this.trackingPlatform.promotionsList(t),this.sentPromotions=new Set([...Array.from(this.sentPromotions),...Array.from(this.sendPromotions)]),this.sendPromotions.clear()}},new((i=void 0)||(i=Promise))((function(s,n){function a(t){try{c(r.next(t))}catch(t){n(t)}}function o(t){try{c(r.throw(t))}catch(t){n(t)}}function c(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,o)}c((r=r.apply(t,e||[])).next())}));var t,e,i,r}}class ht extends ut{}class lt extends ot{getAllItemsList(){return[new dt,new ht]}}class gt extends o{createAddToCartEvent(){this.actionTrackingEvents.push(new l)}createCartViewEvent(){if("cart"===this.trackingConfig.context.page.controller_name){const t=new m;this.actionTrackingEvents.push(t),this.dataTrackingEvents.push(t)}}createCategoryEvent(){"category"===this.trackingConfig.context.page.controller_name&&this.actionTrackingEvents.push(new y)}createCheckoutEvent(){if(this.trackingConfig.context.page.controller_name===this.trackingConfig.context.tracking_module.checkout_module.controller){const t=new N;this.actionTrackingEvents.push(t),this.dataTrackingEvents.push(t)}}createCustomerLogin(){this.trackingConfig.context.user.is_new_login&&this.actionTrackingEvents.push(new R)}createCustomerSignUp(){this.trackingConfig.context.user.is_new_account&&this.actionTrackingEvents.push(new B)}createHomeEvent(){this.actionTrackingEvents.push(new U)}createOrderCompleteEvent(){this.dataTrackingEvents.push(new K)}createProductClickEvent(){this.actionTrackingEvents.push(new G)}createProductShareEvent(){const t=new X;this.actionTrackingEvents.push(t),"product"===this.trackingConfig.context.page.controller_name&&this.dataTrackingEvents.push(t)}createProductViewEvent(){const t=new Z;this.actionTrackingEvents.push(t),"product"===this.trackingConfig.context.page.controller_name&&this.dataTrackingEvents.push(t)}createPromotionClickEvent(){this.actionTrackingEvents.push(new st)}createSearchEvent(){new RegExp("search").test(this.trackingConfig.context.page.controller_name)&&this.actionTrackingEvents.push(new at)}createViewItemsListEvent(){this.actionTrackingEvents.push(new lt)}}class pt{static getEventFactory(){switch(t.getContext().getTrackingConfig().context.tracking_module.service_version){case"7":case"8":return new gt;default:throw Error("Unable to load event manager")}}}class mt{static getProductPosition(t,e){let i=0;const r=mt.getProductThemeData(t),s=JSON.stringify(r);return Object.prototype.hasOwnProperty.call(e,s)&&(i=e[s]),i}static getProductAttribution(t,e){let i=null;const r=mt.getProductThemeData(t),s=JSON.stringify(r);return Object.prototype.hasOwnProperty.call(e,s)&&(i=e[s]),i}static getProductThemeData(t){return{idProduct:t.id_product,idProductAttribute:t.id_attribute}}}class vt{static getCartProducts(t,e){const i=[];return t.forEach((t=>{const r=e.find((e=>e.id_index===t.id_index));r&&i.push(vt.getProductData(t,r.quantity))})),i}static getProductData(t,e,i,r){const s={attributes:t.attributes,category_path:t.category_path,condition:t.condition,ean:t.ean,id_attribute:t.id_attribute,id_category:t.id_category,id_index:t.id_index,id_manufacturer:t.id_manufacturer,id_product:t.id_product,is_available:t.is_available,isbn:t.isbn,manufacturer_name:t.manufacturer_name,name:t.name,mpn:t.mpn,price_sale:t.price_sale,price_main:t.price_main,price_main_tax_excl:t.price_main_tax_excl,price_sale_tax_excl:t.price_sale_tax_excl,price_discount:vt.getItemDiscount(t,!0),price_discount_tax_excl:vt.getItemDiscount(t),reference:t.reference,upc:t.upc};return e&&(s.quantity=e),i&&(s.list_name=i),r&&(s.list_index=r),s}static getItemDiscount(t,e=!1){let i=0;const r=e?t.price_main:t.price_main_tax_excl,s=e?t.price_sale:t.price_sale_tax_excl;return r>s&&(i=(Math.trunc(100*r)-Math.trunc(100*s))/100),i}}class yt{constructor(){this.layer={},this.trackingConfig=t.getContext().getTrackingConfig()}decorate(){return{common_model:this.layer}}initConfig(){return this.layer={},this.decorate()}homePageView(){return this.layer={},this.decorate()}categoryPageView(){return this.layer={},this.decorate()}productsList(t,e){const i=[],r=this.trackingConfig.context.page.controller_name;return t.forEach((t=>{const s=mt.getProductPosition(t,e);i.push(vt.getProductData(t,0,r,s))})),this.layer={items:i},this.decorate()}productClick(t,e){let i=0,r=this.trackingConfig.context.page.controller_name;const s=mt.getProductAttribution(t,e),n=[];return s&&(i=s.productPosition,r=s.productList),n.push(vt.getProductData(t,0,r,i)),this.layer={items:n},this.decorate()}productView(t){const e=[];return e.push(vt.getProductData(t)),this.layer={items:e},this.decorate()}productShare(t,e){const i=[];return i.push(vt.getProductData(t)),this.layer={items:i,parameters:{method:e}},this.decorate()}addToCart(t,e){const i=[];return i.push(vt.getProductData(t,e)),this.layer={items:i},this.decorate()}removeFromCart(t,e){const i=[];return i.push(vt.getProductData(t,e)),this.layer={items:i},this.decorate()}cartView(t,e){const i=vt.getCartProducts(t,e);return this.layer={items:i},this.decorate()}checkoutProgress(t,e,i){const r=vt.getCartProducts(t,e);return this.layer={items:r,checkout:{step:i}},this.decorate()}checkoutOption(t,e,i,r,s){return this.layer={checkout:{step:i,option_type:t,option_value:e}},r&&s&&(this.layer.items=vt.getCartProducts(r,s)),this.decorate()}orderComplete(t,e,i){const r=vt.getCartProducts(e,i),s=Object.assign({},t);return this.layer={items:r,order:s},this.decorate()}promotionsList(t){const e=[];return t.forEach((t=>{const i=Object.assign(Object.assign({},t.promotion_params),t.promotion_item);e.push(i)})),this.layer={items:e},this.decorate()}promotionClick(t){return this.layer={items:[Object.assign(Object.assign({},t.promotion_params),t.promotion_item)]},this.decorate()}searchPageView(){return this.layer={},this.decorate()}customerLogin(){return this.layer={},this.decorate()}customerSignUp(){return this.layer={},this.decorate()}resetLayer(){return this.layer={items:void 0,parameters:void 0},this.decorate()}}class ft{constructor(e){this.eventLayer=e,this.layer={},this.eventTimeout=1e3,this.trackingConfig=t.getContext().getTrackingConfig()}resetLayer(){return this.layer.event="reset_common_model",Object.assign(Object.assign({},this.layer),this.eventLayer.resetLayer())}initConfig(){return this.layer={config:this.getConfigData(),context:this.getContextData()},Object.assign(Object.assign({},this.layer),this.eventLayer.initConfig())}getConfigData(){return{bing:this.trackingConfig.bing,criteo:this.trackingConfig.criteo,facebook:this.trackingConfig.facebook,ga4:this.trackingConfig.ga4,gads:this.trackingConfig.gads,gfeeds:this.trackingConfig.gfeeds,kelkoo:this.trackingConfig.kelkoo,pinterest:this.trackingConfig.pinterest,twitter:this.trackingConfig.twitter,tiktok:this.trackingConfig.tiktok}}getContextData(){return{browser:Object.assign(Object.assign({},this.trackingConfig.context.browser),{user_agent:navigator.userAgent,navigator_lang:navigator.language}),page:{controller_name:this.trackingConfig.context.page.controller_name,category:this.trackingConfig.context.page.category,search_term:this.trackingConfig.context.page.search_term},localization:this.trackingConfig.context.localization,shop:this.trackingConfig.context.shop,user:this.trackingConfig.context.user}}homePageView(){return this.setEventModel("view_home"),Object.assign(Object.assign({},this.layer),this.eventLayer.homePageView())}categoryPageView(){return this.setEventModel("view_category"),Object.assign(Object.assign({},this.layer),this.eventLayer.categoryPageView())}searchPageView(){return this.setEventModel("view_search"),Object.assign(Object.assign({},this.layer),this.eventLayer.searchPageView())}productsList(t,e){return this.setEventModel("view_product_list"),Object.assign(Object.assign({},this.layer),this.eventLayer.productsList(t,e))}productClick(t,e){return this.setEventModel("product_click"),Object.assign(Object.assign({},this.layer),this.eventLayer.productClick(t,e))}productView(t){return this.setEventModel("view_product"),Object.assign(Object.assign({},this.layer),this.eventLayer.productView(t))}productShare(t,e){return this.setEventModel("share_product"),Object.assign(Object.assign({},this.layer),this.eventLayer.productShare(t,e))}addToCart(t,e){return this.setEventModel("add_to_cart"),Object.assign(Object.assign({},this.layer),this.eventLayer.addToCart(t,e))}removeFromCart(t,e){return this.setEventModel("remove_from_cart"),Object.assign(Object.assign({},this.layer),this.eventLayer.removeFromCart(t,e))}cartView(t,e){return this.setEventModel("view_cart"),Object.assign(Object.assign({},this.layer),this.eventLayer.cartView(t,e))}checkoutProgress(t,e,i){return this.setEventModel("checkout_progress"),Object.assign(Object.assign({},this.layer),this.eventLayer.checkoutProgress(t,e,i))}checkoutOption(t,e,i,r,s){return this.setEventModel("checkout_option"),Object.assign(Object.assign({},this.layer),this.eventLayer.checkoutOption(t,e,i,r,s))}orderComplete(t,e,i,r,s){return this.setEventModel("purchase"),this.layer.context=this.getContextData(),this.layer.context.user=r,Object.assign(Object.assign(Object.assign({},this.layer),this.eventLayer.orderComplete(t,e,i,r)),{eventCallback:(...e)=>{this.trackingConfig&&e[0]===this.trackingConfig.gtm.tracking_id&&s(t)},eventTimeout:this.eventTimeout})}promotionsList(t){return this.setEventModel("view_promotion_list"),Object.assign(Object.assign({},this.layer),this.eventLayer.promotionsList(t))}promotionClick(t){return this.setEventModel("promotion_click"),Object.assign(Object.assign({},this.layer),this.eventLayer.promotionClick(t))}customerSignUp(){return this.setEventModel("customer_sign_up"),Object.assign(Object.assign({},this.layer),this.eventLayer.customerSignUp())}customerLogin(){return this.setEventModel("customer_login"),Object.assign(Object.assign({},this.layer),this.eventLayer.customerLogin())}setEventModel(t){this.layer={event:t}}}class kt{constructor(){const t=new yt;this.dataLayerComponent=new ft(t)}}class Pt{constructor(){this.dataLayer={},this.trackingConfig=t.getContext().getTrackingConfig(),this.dataLayerComponent=(new kt).dataLayerComponent}isAvailable(){return Boolean(this.getTrackingId()&&Object.prototype.hasOwnProperty.call(window,"google_tag_manager"))}getScriptURL(){return this.trackingConfig.gtm.server_url||"https://www.googletagmanager.com/gtm.js"}getTrackingId(){return this.trackingConfig.gtm.tracking_id}initConfig(){this.dataLayer=this.dataLayerComponent.initConfig(),this.pushDataLayer()}pushDataLayer(){window.dataLayer=window.dataLayer||[],window.dataLayer.push(this.dataLayer),this.resetDataLayer()}resetDataLayer(){this.dataLayer={}}initScripts(){this.addGTMScript()}addGTMScript(){const t=document.createElement("script");t.innerText=`\n (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':\n new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],\n j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=\n '${this.getScriptURL()}?id='+i+dl;f.parentNode.insertBefore(j,f);\n })(window, document, 'script', 'dataLayer', '${this.getTrackingId()}');\n `,document.head.appendChild(t)}homePageView(){this.dataLayer=this.dataLayerComponent.homePageView(),this.pushDataLayer()}categoryPageView(){this.dataLayer=this.dataLayerComponent.categoryPageView(),this.pushDataLayer()}searchPageView(){this.dataLayer=this.dataLayerComponent.searchPageView(),this.pushDataLayer()}productShare(t,e){this.resetLayer(),this.dataLayer=this.dataLayerComponent.productShare(t,e),this.pushDataLayer()}customerSignUp(){this.dataLayer=this.dataLayerComponent.customerSignUp(),this.pushDataLayer()}customerLogin(){this.dataLayer=this.dataLayerComponent.customerLogin(),this.pushDataLayer()}productsList(t,e){this.resetLayer(),this.dataLayer=this.dataLayerComponent.productsList(t,e),this.pushDataLayer()}productClick(t,e){this.resetLayer(),this.dataLayer=this.dataLayerComponent.productClick(t,e),this.pushDataLayer()}productView(t){this.resetLayer(),this.dataLayer=this.dataLayerComponent.productView(t),this.pushDataLayer()}addToCart(t,e){this.resetLayer(),this.dataLayer=this.dataLayerComponent.addToCart(t,e),this.pushDataLayer()}removeFromCart(t,e){this.resetLayer(),this.dataLayer=this.dataLayerComponent.removeFromCart(t,e),this.pushDataLayer()}cartView(t,e){this.resetLayer(),this.dataLayer=this.dataLayerComponent.cartView(t,e),this.pushDataLayer()}checkoutProgress(t,e,i){this.resetLayer(),this.dataLayer=this.dataLayerComponent.checkoutProgress(t,e,i),this.pushDataLayer()}checkoutOption(t,e,i,r,s){this.resetLayer(),this.dataLayer=this.dataLayerComponent.checkoutOption(t,e,i,r,s),this.pushDataLayer()}orderComplete(t,e,i,r,s){this.resetLayer(),this.dataLayer=this.dataLayerComponent.orderComplete(t,e,i,r,s),this.pushDataLayer()}promotionsList(t){this.resetLayer(),this.dataLayer=this.dataLayerComponent.promotionsList(t),this.pushDataLayer()}promotionClick(t){this.resetLayer(),this.dataLayer=this.dataLayerComponent.promotionClick(t),this.pushDataLayer()}resetLayer(){this.dataLayer=this.dataLayerComponent.resetLayer(),this.pushDataLayer()}}Object.hasOwnProperty.call(window,"RCPGTMClient")||(window.RCPGTMClient=new class extends a{constructor(){super(),this.trackingConfig&&this.sessionStorage&&(this.gtm=new Pt,this.context.setTrackingPlatform(this.gtm),this.eventManager=pt.getEventFactory(),this.init())}getTrackingConfigNode(){return"#js-rcpgtm-tracking-config"}getTrackingDataNode(){return"#js-rcpgtm-tracking-data"}init(){this.initTracking(),this.initEvents()}initTracking(){var t,e;null===(t=this.gtm)||void 0===t||t.initConfig(),null===(e=this.gtm)||void 0===e||e.initScripts()}initEvents(){this.eventManager&&("loading"===document.readyState?document.addEventListener("DOMContentLoaded",this.eventManager.initPageEvents.bind(this.eventManager),!1):this.eventManager.initPageEvents(),"complete"!==document.readyState?window.addEventListener("load",this.initTrackingDataEvents.bind(this),!1):this.initTrackingDataEvents())}initTrackingDataEvents(){this.trackingData=n.getTemplateData(this.getTrackingDataNode()),this.context.setTrackingData(this.trackingData),Object.keys(this.trackingData).length&&this.sessionStorage&&this.eventManager&&(this.sessionStorage.initTrackingData(this.trackingData),this.eventManager.initDataEvents(this.trackingData))}})})();