"use strict";(self.__LOADABLE_LOADED_CHUNKS__=self.__LOADABLE_LOADED_CHUNKS__||[]).push([[59962],{59962:(t,r,e)=>{e.d(r,{t:()=>A});var n=e(67294),a=e(86706),o=e(74782),u=e(24702),i=e(28489);function c(t,r,e,n,a,o,u){try{var i=t[o](u),c=i.value}catch(t){return void e(t)}i.done?r(c):Promise.resolve(c).then(n,a)}var l,s,f=function(t,r){var e,n,a,o,u={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:i(0),throw:i(1),return:i(2)},"function"===typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function i(o){return function(i){return function(o){if(e)throw new TypeError("Generator is already executing.");for(;u;)try{if(e=1,n&&(a=2&o[0]?n.return:o[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,o[1])).done)return a;switch(n=0,a&&(o=[2&o[0],a.value]),o[0]){case 0:case 1:a=o;break;case 4:return u.label++,{value:o[1],done:!1};case 5:u.label++,n=o[1],o=[0];continue;case 7:o=u.ops.pop(),u.trys.pop();continue;default:if(!(a=(a=u.trys).length>0&&a[a.length-1])&&(6===o[0]||2===o[0])){u=0;continue}if(3===o[0]&&(!a||o[1]>a[0]&&o[1]t.length)&&(r=t.length);for(var e=0,n=new Array(r);e0&&a[a.length-1])&&(6===o[0]||2===o[0])){u=0;continue}if(3===o[0]&&(!a||o[1]>a[0]&&o[1]0&&void 0!==arguments[0]?arguments[0]:{needAddToCartGTMEvent:!0},r=t.needAddToCartGTMEvent,e=t.keepSideNavOpen,u=(0,a.I0)(),i=(0,v.t)(),c=(0,a.v9)(h.np),l=g((0,n.useState)(!1),2),s=l[0],f=l[1],m=g((0,n.useState)([]),2),k=m[0],A=m[1],x=(0,n.useRef)(!0),T=(0,n.useRef)(c.products);(0,n.useEffect)((function(){JSON.stringify(c.products)!==JSON.stringify(T.current)&&(T.current=c.products)}),[c.products]),(0,n.useEffect)((function(){r&&k.length>0&&!x.current&&(x.current=!0,i.addToCart((0,b.$z)(k)))}),[k,i,r]);var E=(0,n.useCallback)((function(){u((0,w.f5)(!0)),u((0,w.rf)("cart")),u((0,w.XD)())}),[u]),O=(0,n.useCallback)((function(){u((0,w.f5)(!1)),!e&&setTimeout((function(){return u((0,w.XD)())}),1e3)}),[u,e]),_=(0,n.useCallback)(function(){var t=C((function(t,r,e,n){var a,i,c;return S(this,(function(l){switch(l.label){case 0:if(a=function(t){u((0,h.J9)((0,b.BV)(t)))},i=function(t){var r=t.filter((function(t){return e.includes("".concat(t.idArticle))}));r.length>0&&(A(r),x.current=!1)},!((null===t||void 0===t?void 0:t.updated)||(null===t||void 0===t?void 0:t.deleted)||(null===t||void 0===t?void 0:t.inserted)))return[3,4];(0,p.QV)(),l.label=1;case 1:return l.trys.push([1,3,,4]),[4,(0,o.jf)(r)];case 2:return(c=l.sent())&&(a(c.articles),i(c.articles)),[3,4];case 3:return l.sent(),f(!1),!n&&O(),[3,4];case 4:return f(!1),!n&&O(),[2]}}))}));return function(r,e,n,a){return t.apply(this,arguments)}}(),[u,O]),D=(0,n.useCallback)(function(){var t=C((function(t,r){var e,n,a,o,u;return S(this,(function(i){switch(i.label){case 0:if(e=t,!c.idCart)throw new Error("cart id is not defined");f(!0),!r&&E(),(n=T.current.find((function(r){return r.internalId===+t.idArticle})))&&(e.qty="".concat(n.qty+ +t.qty)),i.label=1;case 1:return i.trys.push([1,5,,6]),[4,(0,y.X)(c.idCart,e)];case 2:return a=i.sent(),o=[t.idArticle],a?[4,_(a,c.idCart,o,r)]:[3,4];case 3:i.sent(),i.label=4;case 4:return[3,6];case 5:throw u=i.sent(),f(!1),!r&&O(),u;case 6:return[2]}}))}));return function(r,e){return t.apply(this,arguments)}}(),[_,O,E,c.idCart]),P=(0,n.useCallback)(function(){var t=C((function(t,r){var e,n,a;return S(this,(function(o){switch(o.label){case 0:if(!c.idCart)throw new Error("cart id is not defined");f(!0),!r&&E(),o.label=1;case 1:return o.trys.push([1,5,,6]),[4,d(c.idCart,t)];case 2:return e=o.sent(),n=t.map((function(t){return t.articleId})),e?[4,_(e,c.idCart,n,r)]:[3,4];case 3:o.sent(),o.label=4;case 4:return[3,6];case 5:throw a=o.sent(),f(!1),!r&&O(),a;case 6:return[2]}}))}));return function(r,e){return t.apply(this,arguments)}}(),[_,O,E,c.idCart]);return{addToCart:D,addMultipleArticlesToCart:P,isAddingToCart:s}}},92476:(t,r,e)=>{e.d(r,{X:()=>l,d:()=>s});var n=e(24702),a=e(28489);function o(t,r,e,n,a,o,u){try{var i=t[o](u),c=i.value}catch(t){return void e(t)}i.done?r(c):Promise.resolve(c).then(n,a)}function u(t){return function(){var r=this,e=arguments;return new Promise((function(n,a){var u=t.apply(r,e);function i(t){o(u,n,a,i,c,"next",t)}function c(t){o(u,n,a,i,c,"throw",t)}i(void 0)}))}}var i,c=function(t,r){var e,n,a,o,u={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:i(0),throw:i(1),return:i(2)},"function"===typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function i(o){return function(i){return function(o){if(e)throw new TypeError("Generator is already executing.");for(;u;)try{if(e=1,n&&(a=2&o[0]?n.return:o[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,o[1])).done)return a;switch(n=0,a&&(o=[2&o[0],a.value]),o[0]){case 0:case 1:a=o;break;case 4:return u.label++,{value:o[1],done:!1};case 5:u.label++,n=o[1],o=[0];continue;case 7:o=u.ops.pop(),u.trys.pop();continue;default:if(!(a=(a=u.trys).length>0&&a[a.length-1])&&(6===o[0]||2===o[0])){u=0;continue}if(3===o[0]&&(!a||o[1]>a[0]&&o[1]