marketing/autocart.js

1 line
31 KiB
JavaScript
Raw Normal View History

2026-08-21 15:23:20 +00:00
const _0x343057=_0x56a4;(function(_0x5d7703,_0x3f42ab){const _0x2ff2ef=_0x56a4,_0x47dd1a=_0x5d7703();while(!![]){try{const _0x286c6e=-parseInt(_0x2ff2ef(0x143))/0x1+-parseInt(_0x2ff2ef(0x113))/0x2+-parseInt(_0x2ff2ef(0xeb))/0x3*(-parseInt(_0x2ff2ef(0x117))/0x4)+parseInt(_0x2ff2ef(0xf5))/0x5+-parseInt(_0x2ff2ef(0x182))/0x6+-parseInt(_0x2ff2ef(0x11d))/0x7+parseInt(_0x2ff2ef(0x15a))/0x8;if(_0x286c6e===_0x3f42ab)break;else _0x47dd1a['push'](_0x47dd1a['shift']());}catch(_0x3fe7c1){_0x47dd1a['push'](_0x47dd1a['shift']());}}}(_0x1dab,0x879fd));const host=_0x343057(0x16b);function throttle(_0xa9dfd,_0x139fe1,_0x39846d){var _0x508961,_0x4d3cdc,_0x3e5785,_0x4883c6=null,_0x55c21f=0x0;if(!_0x39846d)_0x39846d={};var _0x15f787=function(){const _0x159c84=_0x56a4;_0x55c21f=_0x39846d[_0x159c84(0x111)]===![]?0x0:Date[_0x159c84(0x171)](),_0x4883c6=null,_0x3e5785=_0xa9dfd['apply'](_0x508961,_0x4d3cdc);if(!_0x4883c6)_0x508961=_0x4d3cdc=null;};return function(){const _0x1757fc=_0x56a4;var _0x1bc841=Date['now']();if(!_0x55c21f&&_0x39846d['leading']===![])_0x55c21f=_0x1bc841;var _0x3f75b7=_0x139fe1-(_0x1bc841-_0x55c21f);_0x508961=this,_0x4d3cdc=arguments;if(_0x3f75b7<=0x0||_0x3f75b7>_0x139fe1){_0x4883c6&&(clearTimeout(_0x4883c6),_0x4883c6=null);_0x55c21f=_0x1bc841,_0x3e5785=_0xa9dfd['apply'](_0x508961,_0x4d3cdc);if(!_0x4883c6)_0x508961=_0x4d3cdc=null;}else!_0x4883c6&&_0x39846d[_0x1757fc(0xed)]!==![]&&(_0x4883c6=setTimeout(_0x15f787,_0x3f75b7));return _0x3e5785;};}function refreshToken(){const _0x350832=_0x343057;return fetch(host+_0x350832(0x174),{'method':_0x350832(0x15e),'credentials':_0x350832(0x14d)})[_0x350832(0xf2)](_0x153c62=>{const _0x3e108c=_0x350832;return _0x153c62[_0x3e108c(0x16c)]();});}function initToken(){const _0x4ed4fb=_0x343057;return fetch(host+'/api/guest/init_cookie?utm_source=hvatilo_promo',{'method':_0x4ed4fb(0x15e),'credentials':_0x4ed4fb(0x14d)})['then'](_0x319685=>{const _0x4f7448=_0x4ed4fb;return _0x319685[_0x4f7448(0x16c)]();});}const requestWithRefresh=async function(_0x138c2e,_0x5ef742){const _0x556312=_0x343057;return fetch(_0x138c2e,{..._0x5ef742,'credentials':_0x556312(0x14d)})['then'](async _0x2281c3=>_0x2281c3[_0x556312(0x16c)]())[_0x556312(0xf2)](async _0x448a3b=>{const _0x4a25cd=_0x556312;if(_0x448a3b[_0x4a25cd(0x184)]===_0x4a25cd(0xd8))return refreshToken()[_0x4a25cd(0xf2)](_0x253b5d=>{const _0x15ef73=_0x4a25cd;return console[_0x15ef73(0x17e)](_0x15ef73(0x166),_0x138c2e),fetch(_0x138c2e,{..._0x5ef742,'credentials':_0x15ef73(0x14d)})[_0x15ef73(0xf2)](_0x21165b=>_0x21165b[_0x15ef73(0x16c)]());});return _0x448a3b;});},replaceProduct=async function(_0x3839d3){const _0x21ac89=_0x343057;return requestWithRefresh(host+_0x21ac89(0x170),{'method':_0x21ac89(0x15e),'headers':{'Content-Type':_0x21ac89(0x100)},'body':JSON[_0x21ac89(0xe4)]({'product_name':_0x3839d3})})[_0x21ac89(0xf2)](async()=>{updateCart();});},deleteProduct=async function(_0x285169){const _0x5dbd91=_0x343057;return requestWithRefresh(host+_0x5dbd91(0x12a),{'method':_0x5dbd91(0x15e),'headers':{'Content-Type':_0x5dbd91(0x100)},'body':JSON[_0x5dbd91(0xe4)]({'product_name':_0x285169})});},updateCart=throttle(async function(){const _0x41ad55=_0x343057;return requestWithRefresh(host+_0x41ad55(0xf7),{'headers':{'Content-Type':_0x41ad55(0x100)}})['then'](_0x4e9284=>{const _0x48419d=_0x41ad55;_0x4e9284[_0x48419d(0xbb)]!=='complete'&&(initialData_g[_0x48419d(0x16f)]=_0x4e9284[_0x48419d(0xd4)][_0x48419d(0x16f)],initialData_g[_0x48419d(0x13a)]=_0x4e9284[_0x48419d(0xd4)][_0x48419d(0x13a)],_0x4e9284[_0x48419d(0xbb)]===_0x48419d(0x115)&&(allProducts=[],visibleProducts=[],renderProducts(),allProducts=_0x4e9284[_0x48419d(0xd4)][_0x48419d(0x133)],visibleProducts=_0x4e9284[_0x48419d(0xd4)][_0x48419d(0x133)]),_0x4e9284[_0x48419d(0xbb)]===_0x48419d(0xdd)&&_0x4e9284[_0x48419d(0xd4)]['chunk'][_0x48419d(0x169)](_0x48205b=>{const _0xa73b92=_0x48419d;let _0x5625d7=allProducts['findIndex'](_0x168128=>_0x168128[_0xa73b92(0x176)]===_0x48205b[_0xa73b92(0x176)]);_0x5625d7===-0x1?(allProducts[_0xa73b92(0x162)]({..._0x48205b,'image':_0x48205b[_0xa73b92(0x17f)]?.[_0xa73b92(0x132)](_0