marketing/autocart.js

1 line
89 KiB
JavaScript
Raw Permalink Normal View History

2026-08-22 18:51:25 +00:00
'use strict';const _0x4fba01=_0x12da;(function(_0x35e69d,_0x489515){const _0x2a289b=_0x12da,_0x4be6da=_0x35e69d();while(!![]){try{const _0x3d626e=parseInt(_0x2a289b(0x322))/0x1+parseInt(_0x2a289b(0x1bf))/0x2*(parseInt(_0x2a289b(0x24e))/0x3)+parseInt(_0x2a289b(0x20b))/0x4+-parseInt(_0x2a289b(0x23d))/0x5+-parseInt(_0x2a289b(0x2c1))/0x6*(parseInt(_0x2a289b(0x2ea))/0x7)+parseInt(_0x2a289b(0x319))/0x8+-parseInt(_0x2a289b(0x1c5))/0x9;if(_0x3d626e===_0x489515)break;else _0x4be6da['push'](_0x4be6da['shift']());}catch(_0x1ba005){_0x4be6da['push'](_0x4be6da['shift']());}}}(_0x4743,0xa6654));const host=_0x4fba01(0x239);function throttle(_0x14c962,_0x3425b6,_0x41fa1e){var _0x341b20,_0x4af32c,_0x4106e5,_0x260d42=null,_0x5ed0c9=0x0;if(!_0x41fa1e)_0x41fa1e={};var _0x469639=function(){const _0xd4a7c0=_0x12da;_0x5ed0c9=_0x41fa1e[_0xd4a7c0(0x1e3)]===![]?0x0:Date[_0xd4a7c0(0x2e8)](),_0x260d42=null,_0x4106e5=_0x14c962[_0xd4a7c0(0x1d7)](_0x341b20,_0x4af32c);if(!_0x260d42)_0x341b20=_0x4af32c=null;};return function(){const _0x4d6e69=_0x12da;var _0x4f4952=Date['now']();if(!_0x5ed0c9&&_0x41fa1e[_0x4d6e69(0x1e3)]===![])_0x5ed0c9=_0x4f4952;var _0x77039=_0x3425b6-(_0x4f4952-_0x5ed0c9);_0x341b20=this,_0x4af32c=arguments;if(_0x77039<=0x0||_0x77039>_0x3425b6){_0x260d42&&(clearTimeout(_0x260d42),_0x260d42=null);_0x5ed0c9=_0x4f4952,_0x4106e5=_0x14c962[_0x4d6e69(0x1d7)](_0x341b20,_0x4af32c);if(!_0x260d42)_0x341b20=_0x4af32c=null;}else!_0x260d42&&_0x41fa1e['trailing']!==![]&&(_0x260d42=setTimeout(_0x469639,_0x77039));return _0x4106e5;};}function refreshToken(){const _0x5dce16=_0x4fba01;return fetch(host+_0x5dce16(0x32e),{'method':_0x5dce16(0x2ec),'credentials':_0x5dce16(0x1f3)})['then'](_0x409e94=>{const _0x56904d=_0x5dce16;if(_0x409e94[_0x56904d(0x25a)]===0x190)return fetch(host+_0x56904d(0x2b9),{'method':'POST','credentials':_0x56904d(0x1f3)})[_0x56904d(0x277)](async _0x35b055=>{return await new Promise(_0x168bf5=>setTimeout(_0x168bf5,0x64)),initToken();});return _0x409e94[_0x56904d(0x2cb)]();});}function initToken(){const _0x17146d=_0x4fba01;return fetch(host+'/api/guest/init_cookie?utm_source=hvatilo_promo',{'method':_0x17146d(0x2ec),'credentials':'include'})['then'](_0x17432c=>{const _0x5162c6=_0x17146d;return _0x17432c[_0x5162c6(0x2cb)]();});}const requestWithRefresh=async function(_0x348adc,_0x7572f4){const _0x53b92b=_0x4fba01;return fetch(_0x348adc,{..._0x7572f4,'credentials':_0x53b92b(0x1f3)})[_0x53b92b(0x277)](async _0x2ac6d7=>_0x2ac6d7[_0x53b92b(0x2cb)]())[_0x53b92b(0x277)](async _0x2b5a7a=>{const _0x1c6f27=_0x53b92b;if(_0x2b5a7a[_0x1c6f27(0x281)]===_0x1c6f27(0x193))return refreshToken()[_0x1c6f27(0x277)](_0x115423=>{const _0xcf3bcc=_0x1c6f27;return console['log'](_0xcf3bcc(0x241),_0x348adc),fetch(_0x348adc,{..._0x7572f4,'credentials':_0xcf3bcc(0x1f3)})[_0xcf3bcc(0x277)](_0x39058b=>_0x39058b[_0xcf3bcc(0x2cb)]());});return _0x2b5a7a;});},replaceProduct=async function(_0x1d5410){const _0x5787d5=_0x4fba01;return requestWithRefresh(host+'/api/promo/replace_item',{'method':_0x5787d5(0x2ec),'headers':{'Content-Type':'application/json'},'body':JSON[_0x5787d5(0x280)]({'product_name':_0x1d5410})})[_0x5787d5(0x277)](async()=>{updateCart();});},deleteProduct=async function(_0x4d548d){const _0x148dad=_0x4fba01;return requestWithRefresh(host+_0x148dad(0x28e),{'method':_0x148dad(0x2ec),'headers':{'Content-Type':_0x148dad(0x2fa)},'body':JSON[_0x148dad(0x280)]({'product_name':_0x4d548d})});},updateCart=throttle(async function(){const _0xcc75f7=_0x4fba01;return document['getElementById']('summary-loader')['classList'][_0xcc75f7(0x2c2)](_0xcc75f7(0x155)),document['getElementById'](_0xcc75f7(0x2cf))[_0xcc75f7(0x27a)]['add'](_0xcc75f7(0x155)),requestWithRefresh(host+'/api/promo/get_updates',{'headers':{'Content-Type':_0xcc75f7(0x2fa)}})['then'](_0x72949=>{const _0x2b7ee2=_0xcc75f7;_0x72949[_0x2b7ee2(0x25a)]!==_0x2b7ee2(0x1b6)?(initialData_g[_0x2b7ee2(0x302)]=_0x72949[_0x2b7ee2(0x191)][_0x2b7ee2(0x302)],initialData_g['precision']=_0x72949[_0x2b7ee2(0x191)][_0x2b7ee2(0x248)],_0x72949['status']===_0x2b7ee2(0x153)&&(allProducts=[],visibleProducts=[],renderProducts(),