define(['jquery','uiComponent','underscore','Magento_Customer/js/customer-data'],function($,Component,_,customerData){'use strict';return Component.extend({initialize:function(){this._super();const gtm=customerData.get('mst-gtm-addtocart');customerData.reload(['mst-gtm-addtocart'],false);gtm.subscribe(this.onUpdate);},onUpdate:function(data){var mstGtmStorage=window.sessionStorage.getItem('mst_gtm');mstGtmStorage=mstGtmStorage?mstGtmStorage.split('|'):[];_.each(data.push,function(item){var gtmStorageKey='';if(typeof item.gtm_id!='undefined'){gtmStorageKey=item.gtm_id;} if(item&&typeof item.gtm_id!='undefined'&&!mstGtmStorage.includes(gtmStorageKey)){window.dataLayer.push({ecommerce:null});if(typeof item.analytics_type!='undefined'&&item.analytics_type=='ga3'){window.dataLayer.push(item);}else if(typeof item.analytics_type!='undefined'&&item.analytics_type=='fbpixel'){if(typeof fbq!='undefined'){fbq(item[0],item[1],item[2]);}}else{if(typeof gtag!='undefined'){gtag(item[0],item[1],item[2]);}else{var formatedObj={};formatedObj[item[0]]=item[1];formatedObj['ecommerce']=item[2];window.dataLayer.push(formatedObj);}}} mstGtmStorage.push(gtmStorageKey);});window.sessionStorage.setItem("mst_gtm",mstGtmStorage.join('|'));}});});