(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1781],{76:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return CartSidebar_CartSidebar}});var r=n(33067),i=n(73888),a=n.n(i),o=n(16652),l=n(13666),c=n(2614),s=n(44194),u=n(71041),d=n(43412),b=n.n(d),useCheckoutButton=()=>{var{isValidating:e,id:t}=(0,u.jD)();return{onClick:n=>{n.preventDefault();var r=window.location.host.includes(".vtex.app")||window.location.host.includes("localhost");!e&&(r?t&&(window.location.href="".concat(b().checkoutUrl,"?orderFormId=").concat(t)):window.location.href="".concat(b().checkoutUrl))},disabled:e,"data-testid":"checkout-button"}},h=n(97358),p=n(94588),m=n.n(p),f=n(31549);function ownKeys(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(n),!0).forEach(function(t){(0,r.Z)(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ownKeys(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var j=a()(()=>Promise.all([n.e(6852),n.e(9465),n.e(9781),n.e(5906)]).then(n.bind(n,49465)).then(e=>e.Button),{ssr:!1,loadableGenerated:{webpack:()=>[null]}}),w=a()(()=>Promise.all([n.e(6852),n.e(9465),n.e(9781),n.e(5906)]).then(n.bind(n,49465)).then(e=>e.CartSidebarFooter),{ssr:!1,loadableGenerated:{webpack:()=>[null]}}),O=a()(()=>Promise.all([n.e(6852),n.e(9465),n.e(9781),n.e(5906)]).then(n.bind(n,49465)).then(e=>e.CartSidebarList),{ssr:!1,loadableGenerated:{webpack:()=>[null]}}),x=a()(()=>Promise.all([n.e(6852),n.e(9465),n.e(9781),n.e(5906)]).then(n.bind(n,49465)).then(e=>e.CartSidebar),{ssr:!1,loadableGenerated:{webpack:()=>[null]}}),v=a()(()=>n.e(1724).then(n.bind(n,96348)),{ssr:!1,loadableGenerated:{webpack:()=>[96348]}}),k=a()(()=>n.e(2985).then(n.bind(n,36683)),{ssr:!1,loadableGenerated:{webpack:()=>[36683]}}),y=a()(()=>n.e(549).then(n.bind(n,39550)),{ssr:!1,loadableGenerated:{webpack:()=>[39550]}}),_=a()(()=>n.e(2553).then(n.bind(n,56768)),{ssr:!1,loadableGenerated:{webpack:()=>[56768]}}),CartSidebar_CartSidebar=function(e){var{title:t,alert:{icon:{icon:r,alt:i},text:a},checkoutButton:{label:d,loadingLabel:b,icon:{icon:p,alt:g}},quantitySelector:P,taxesConfiguration:C}=e,S=useCheckoutButton(),{items:D,gifts:G,totalItems:T,isValidating:F,subTotal:M,total:U,subTotalWithTaxes:B,totalWithTaxes:E}=(0,u.jD)({useUnitMultiplier:null==P?void 0:P.useUnitMultiplier}),{cart:I,closeCart:N}=(0,o.l8)(),{fadeOut:L}=(0,l.b)(),{sendViewCartEvent:K}=function(){var{currency:{code:e}}=(0,h.kP)(),{items:t,gifts:r,total:i}=(0,u.jD)(),a=JSON.stringify(r),o=JSON.stringify(t),l=(0,s.useCallback)(()=>{n.e(9399).then(n.bind(n,66393)).then(n=>{var{sendAnalyticsEvent:a}=n;return a({name:"view_cart",params:{currency:e,value:i,items:t.concat(r).map(t=>({item_id:t.itemOffered.isVariantOf.productGroupID,item_name:t.itemOffered.isVariantOf.name,item_brand:t.itemOffered.brand.name,item_variant:t.itemOffered.sku,quantity:t.quantity,price:t.price,discount:t.listPrice-t.price,currency:e,item_variant_name:t.itemOffered.name,product_reference_id:t.itemOffered.gtin}))}})})},[e,a,o,i]);return(0,s.useMemo)(()=>({sendViewCartEvent:l}),[l])}(),W=(0,s.useMemo)(()=>0===D.length,[D]);return(0,s.useEffect)(()=>{I&&K()},[I,K]),(0,f.jsx)(f.Fragment,{children:I&&(0,f.jsx)(x,{overlayProps:{className:"section ".concat(m().section," section-cart-sidebar")},title:t,totalItems:T,alertIcon:(0,f.jsx)(c.Z,{name:r,"aria-label":i}),alertText:a,onClose:L,children:W?(0,f.jsx)(v,{onDismiss:N}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(O,{children:[D.map(e=>{var t;return(0,f.jsx)("li",{children:(0,f.jsx)(y,{item:e,taxesConfiguration:C,useUnitMultiplier:null!==(t=null==P?void 0:P.useUnitMultiplier)&&void 0!==t&&t})},e.id)}),G.length>0&&(0,f.jsx)(f.Fragment,{children:G.map(e=>(0,f.jsx)("li",{children:(0,f.jsx)(k,{item:e})},e.id))})]}),(0,f.jsx)(w,{children:(0,f.jsx)(_,{subTotal:null!=C&&C.usePriceWithTaxes?B:M,total:null!=C&&C.usePriceWithTaxes?E:U,includeTaxes:null==C?void 0:C.usePriceWithTaxes,includeTaxesLabel:null==C?void 0:C.taxesLabel,numberOfItems:T,checkoutButton:(0,f.jsx)(j,_objectSpread(_objectSpread({variant:"primary",icon:!F&&(0,f.jsx)(c.Z,{name:p,"aria-label":g,width:18,height:18}),iconPosition:"right"},S),{},{children:F?b:d}))})})]})})})}},94588:function(e){e.exports={section:"section_section__yzDFp"}}}]);