1(function(){if(typeof window.LEPIXEL_WOO==='undefined'){return;} 2var cfg=window.LEPIXEL_WOO;var HOST=cfg.TRACKING_SERVER;function nowTs(){return Date.now();} 3function newEventId(){return(''+Date.now())+''+Math.floor(Math.random()*1e16);} 4function headers(){var h={'Content-Type':'application/json'};try{if(cfg&&cfg.nonce){h['X-WP-Nonce']=cfg.nonce;}}catch(e){} 5return h;} 6async function getVisitorId(){try{var id=localStorage.getItem('lePixelVisitorId');if(!id){id='v-'+Date.now()+'-'+Math.floor(Math.random()*1000000);localStorage.setItem('lePixelVisitorId',id);} 7return id;}catch(e){}} 8async function getSessionId(){try{var id=sessionStorage.getItem('lePixelSessionId');if(!id){id='s-'+Date.now()+'-'+Math.floor(Math.random()*1000000);sessionStorage.setItem('lePixelSessionId',id);} 9return id;}catch(e){}} 10function sendTrackingData(payload,retries){retries=(typeof retries==='number')?retries:3;var body=JSON.stringify(payload);try{fetch(HOST,{method:'POST',headers:{'Content-Type':'application/json'},body:body}).catch(function(){try{if(navigator&&typeof navigator.sendBeacon==='function'){var blob=new Blob([body],{type:'application/json'});navigator.sendBeacon(HOST,blob);}}catch(e){} 11if(retries>0){sendTrackingData(payload,retries-1);}});}catch(e){}} 12function baseEvent(evtName,extra){return Promise.all([getVisitorId(),getSessionId()]).then(function(ids){var visitorId=ids[0],sessionId=ids[1];var base={event:evtName,eventId:newEventId(),visitorId:visitorId,url:window.location.href,referrer:document.referrer,timestamp:nowTs(),sessionId:sessionId,shop:cfg.shop,customerId:cfg.user?cfg.user.id:undefined,customerEmail:cfg.user?cfg.user.email:undefined,firstName:cfg.user?cfg.user.firstName:undefined,lastName:cfg.user?cfg.user.lastName:undefined};if(extra){for(var k in extra){base[k]=extra[k];}} 13return base;});} 14function sendPageView(){baseEvent('page_view').then(sendTrackingData);} 15function onJq(eventName,handler){if(typeof jQuery==='undefined'){return;} 16jQuery(function($){$(document.body).on(eventName,handler);});} 17function onDoc(eventName,selector,handler){if(typeof jQuery==='undefined'){return;} 18jQuery(function($){$(document).on(eventName,selector,handler);});} 19function restGet(path){var url=cfg.restRoot.replace(/\/$/,'')+path;return fetch(url,{headers:headers()}).then(function(r){return r.json();});} 20function enrichProduct(productId,variationId,quantity){var qs='?id='+encodeURIComponent(productId)+ 21(variationId?('&variation_id='+encodeURIComponent(variationId)):'')+'&quantity='+encodeURIComponent(quantity||1);return restGet('/product'+qs);} 22function fetchCart(){return restGet('/cart');} 23var cartSnapshot={};var suppressDiffUntil=0;var snapshotReady=false;function updateSnapshot(items){cartSnapshot={};(items||[]).forEach(function(it){cartSnapshot[it.key]={quantity:it.quantity,item:it};});snapshotReady=true;} 24function buildCartPayload(item,deltaQty){var unit=(item&&item.variant&&typeof item.variant.price==='number')?item.variant.price:undefined;return{quantity:deltaQty,totalPrice:(unit?{amount:unit*deltaQty,currency:item.variant.currency||cfg.currency}:undefined),variant:item.variant};} 25function diffEmit(prevMap,nextItems){var nextMap={};nextItems.forEach(function(it){nextMap[it.key]={quantity:it.quantity,item:it};});var keys={};for(var k in prevMap){keys[k]=true;} 26for(var k in nextMap){keys[k]=true;} 27var emits=[];for(var k in keys){var prev=prevMap[k]?prevMap[k].quantity:0;var next=nextMap[k]?nextMap[k].quantity:0;var item=nextMap[k]?nextMap[k].item:(prevMap[k]?prevMap[k].item:null);if(!item){continue;} 28if(next>prev){emits.push({type:'add_to_cart',payload:buildCartPayload(item,next-prev)});}else if(next<prev){emits.push({type:'remove_from_cart',payload:buildCartPayload(item,prev-next)});}} 29emits.sort(function(a,b){return a.type==='remove_from_cart'?-1:1;});var proms=emits.map(function(evt){return baseEvent(evt.type,evt.type==='add_to_cart'?{addedItem:evt.payload}:{removedItem:evt.payload}).then(function(data){sendTrackingData(data,0);});});updateSnapshot(nextItems);return Promise.all(proms);} 30function refreshAndDiff(reason){if(Date.now()<suppressDiffUntil){return;} 31if(!snapshotReady){return;} 32fetchCart().then(function(res){var items=(res&&res.items)?res.items:[];diffEmit(cartSnapshot,items);}).catch(function(){});} 33function suppressFor(ms){suppressDiffUntil=Date.now()+(ms||1200);} 34try{sendPageView();}catch(e){} 35setTimeout(function(){fetchCart().then(function(res){updateSnapshot((res&&res.items)||[]);});},150);onJq('added_to_cart',function(ev,fragments,cart_hash,$button){try{var $btn=(typeof jQuery!=='undefined'&&$button&&$button.length)?$button:null;var productId=$btn?($btn.data('product_id')||$btn.attr('data-product_id')||$btn.data('product')||$btn.attr('data-product')):null;var variationId=$btn?($btn.data('variation_id')||$btn.attr('data-variation_id')):null;var qty=1;try{qty=($btn&&($btn.data('quantity')||$btn.attr('data-quantity')))||1;var $form=$btn&&$btn.closest('form');if($form&&!variationId){var vid=$form.find('input[name=variation_id]').val();if(vid)variationId=parseInt(vid,10);} 36if($form){var qv=$form.find('input[name=quantity]').val();if(qv)qty=parseInt(qv,10);}}catch(e){} 37if(!productId){return;} 38enrichProduct(productId,variationId,qty).then(function(data){baseEvent('add_to_cart',{addedItem:data.addedItem}).then(function(evt){sendTrackingData(evt,0);suppressFor(1200);});}).catch(function(){baseEvent('add_to_cart',{addedItem:{quantity:qty,variant:{id:variationId||productId,product:{id:productId}}}}).then(function(evt){sendTrackingData(evt,0);suppressFor(1200);});});}catch(e){}});onJq('removed_from_cart',function(){setTimeout(function(){refreshAndDiff('removed_from_cart');},200);suppressFor(1200);});try{if(cfg.lastAddedItem){baseEvent('add_to_cart',{addedItem:cfg.lastAddedItem}).then(sendTrackingData);} 39if(cfg.lastRemovedItem){baseEvent('remove_from_cart',{removedItem:cfg.lastRemovedItem}).then(sendTrackingData);}}catch(e){}
40try{if(cfg.context&&cfg.context.isCheckout&&cfg.checkout){baseEvent('initiate_checkout',{totalPrice:cfg.checkout.totalPrice,lineItems:cfg.checkout.lineItems,discountsAmount:cfg.checkout.discountsAmount||undefined,totalTax:cfg.checkout.totalTax,shippingPrice:cfg.checkout.shippingPrice}).then(function(evt){sendTrackingData(evt,0);});}}catch(e){} 41try{if(cfg.purchase){var orderKey=cfg.purchase.orderId;var dedupKey='lePixelPurchase'+orderKey;if(!sessionStorage.getItem(dedupKey)){sessionStorage.setItem(dedupKey,'1');baseEvent('purchase').then(function(base){var p=cfg.purchase;p.eventId=base.eventId;p.visitorId=base.visitorId;p.sessionId=base.sessionId;p.url=base.url;p.referrer=base.referrer;p.timestamp=base.timestamp;p.shop=p.shop||base.shop;sendTrackingData(p,0);});}}}catch(e){} 42onJq('updated_wc_div',function(){refreshAndDiff('updated_wc_div');});onJq('cart_page_refreshed',function(){refreshAndDiff('cart_page_refreshed');});onJq('wc_cart_emptied',function(){refreshAndDiff('wc_cart_emptied');});onJq('wc_fragments_refreshed',function(){refreshAndDiff('wc_fragments_refreshed');});onDoc('click','a.remove, a.remove_from_cart_button, .wc-block-cart-item__remove-link',function(){setTimeout(function(){refreshAndDiff('click_remove');},200);});if(typeof jQuery!=='undefined'){jQuery(document).ajaxSuccess(function(event,xhr,settings){try{if(!settings||!settings.url)return;var url=settings.url;var dataStr=settings.data||'';if(url.indexOf('wc-ajax=add_to_cart')!==-1){var p=new URLSearchParams(dataStr||'');var productId=p.get('product_id')||p.get('add-to-cart');var variationId=p.get('variation_id');var qty=parseInt(p.get('quantity')||'1',10);if(productId){enrichProduct(productId,variationId,qty).then(function(data){baseEvent('add_to_cart',{addedItem:data.addedItem}).then(function(evt){sendTrackingData(evt,0);suppressFor(1200);});});}}else if(url.indexOf('wc-ajax=remove_from_cart')!==-1){setTimeout(function(){refreshAndDiff('ajax_remove');},200);suppressFor(1200);}else if(url.indexOf('wc-ajax=update_cart')!==-1||url.indexOf('wc-ajax=apply_coupon')!==-1){setTimeout(function(){refreshAndDiff('ajax_update');},300);}}catch(e){}});} 43(function(){if(!window.fetch){return;} 44var origFetch=window.fetch;window.fetch=function(input,init){var url=(typeof input==='string')?input:(input&&input.url)||'';var method=(init&&init.method)?String(init.method).toUpperCase():'GET';var p=origFetch.apply(this,arguments);try{if(/wc-ajax=(add_to_cart|remove_from_cart|update_cart)|\/wc\/store\/|\/wp-json\/wc\/store\//.test(url)){p.then(function(){setTimeout(function(){refreshAndDiff('fetch:'+method);},220);});}}catch(e){} 45return p;};})();(function(){if(typeof MutationObserver==='undefined'){return;} 46var sel=['.widget_shopping_cart','.woocommerce-mini-cart','.wc-block-mini-cart','.wc-block-cart-items'].join(',');function observe(el){try{var mo=new MutationObserver(function(){setTimeout(function(){refreshAndDiff('mo');},300);});mo.observe(el,{childList:true,subtree:true,characterData:true});}catch(e){}} 47function scan(){var nodes=document.querySelectorAll(sel);for(var i=0;i<nodes.length;i++){observe(nodes[i]);}} 48if(document.readyState==='loading'){document.addEventListener('DOMContentLoaded',scan);}else{scan();}})();if(typeof jQuery!=='undefined'){jQuery(function($){$(document).on('change','.woocommerce-cart-form input.qty',function(){setTimeout(function(){refreshAndDiff('qty_change');},500);});});}})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.