(function(){function l(){b.log("Checking CartPanda functions...");return typeof window.getAjax!=="undefined"?(b.log("CartPanda detected, installing interceptor..."),q(),!0):!1}function q(){const f=window.getAjax,k=window.postAjax;b.log("Interceptor installed successfully");window.getAjax=function(d,a){b.log("getAjax called");return d==="/cart.json"?(b.log("Intercepting cart.json request"),f(d,function(e){try{const c=JSON.parse(e),g=m(c);a(JSON.stringify(g))}catch(c){b.error("CartPanda interceptor error"), a(e)}})):f(d,a)};window.postAjax=function(d,a,e){b.log("postAjax called");if(d.includes("cartpanda.com")&&typeof a==="string")try{const c=JSON.parse(a);c.cart_payload&&(b.log("Modifying CartPanda cart payload"),c.cart_payload=m(c.cart_payload),a=JSON.stringify(c))}catch(c){b.error("CartPanda postAjax interceptor error")}return k(d,a,e)}}function m(f){if(!f||!f.items||!Array.isArray(f.items))return b.warn("Invalid cart data structure"),f;b.log("Applying discounts to cart data");const k=(100-r)/100; b.log("PIX discount configured");let d=0;f.items=f.items.map(a=>{const e=a.price,c=a.quantity||1;if(a.properties&&a.properties._page_discount_percent){var g=parseFloat(a.properties._page_discount_percent);g=Math.round(Math.round((100-g)/100*e)*k);d+=g*c;var h={...a.properties};delete h._page_discount_percent;delete h._page_template;delete h._cartpanda_modified;return{...a,price:g,line_price:g*c,original_price:e,original_line_price:e*c,properties:h}}g=Math.round(e*k);d+=g*c;h={...a.properties};delete h._page_discount_percent; delete h._page_template;delete h._cartpanda_modified;return{...a,price:g,line_price:g*c,original_price:e,original_line_price:e*c,properties:h}});f.total_price=d;f.items_subtotal_price=d;return f}var b={log:function(){},warn:function(){},error:function(){}};b.log("Interceptor initialized");const n=document.getElementById("cartpanda-config"),r=n?parseFloat(n.dataset.pixDiscount):5;l();(function(){const f=XMLHttpRequest.prototype.open,k=XMLHttpRequest.prototype.send;XMLHttpRequest.prototype.open=function(d, a,...e){this._method=d;this._url=a;return f.call(this,d,a,...e)};XMLHttpRequest.prototype.send=function(d){if(this._url==="/cart.json"&&this._method==="GET"){b.log("XHR: Intercepting cart.json request");const a=this.onload,e=this.onreadystatechange;this.onreadystatechange=function(){if(this.readyState===4&&this.status===200)try{const c=JSON.parse(this.responseText),g=m(c);Object.defineProperty(this,"responseText",{value:JSON.stringify(g),writable:!1});Object.defineProperty(this,"response",{value:JSON.stringify(g), writable:!1});b.log("XHR: Cart data modified successfully")}catch(c){b.error("XHR: Error modifying cart data")}if(e)return e.apply(this,arguments)};a&&(this.onload=function(){b.log("XHR: onload triggered");return a.apply(this,arguments)})}return k.call(this,d)};b.log("XHR override installed")})();let p=0;const t=setInterval(()=>{p++;window.getAjax&&!window._cartpandaInterceptorActive&&(b.log("Retry: Installing getAjax interceptor"),l()&&(window._cartpandaInterceptorActive=!0,b.log("getAjax interceptor active"))); p>=30&&(b.log("Retry attempts completed"),clearInterval(t))},200);setTimeout(()=>{l();b.log("Final interceptor setup complete")},3E3)})();