"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8325],{98325:function(e,r,t){t.r(r),t.d(r,{default:function(){return ProductComparison_ProductComparisonSidebar}});var i=t(33067),a=t(44194),n=t(52182),o=t(98668),u=t(68687),s=t(25487),c=t(52693),f=t(97358),l=s.cD,useProductsSelected=(e,r,t)=>{var{channel:i,locale:n}=(0,f.kP)(),o=(0,a.useMemo)(()=>{if(!i)throw Error("useProductsSelected: 'channel' from session is an empty string.");return{productIds:e}},[i,n,e]);return(0,c.aM)(l,o,{doNotRun:r,onSuccess:e=>t(e)})},d=t(31549);function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);r&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,i)}return t}var m=[{value:"productByName",label:"Product Name",onChange:e=>e.sort((e,r)=>e.name.localeCompare(r.name))},{value:"productByPrice",label:"Price",onChange:e=>e.sort((e,r)=>e.offers.lowPrice-r.offers.lowPrice)}],ProductComparison_ProductComparisonSidebar=function(e){var{productIds:r,products:t,isOpen:s,handleProductsComparison:c}=(0,n.S)(),[f,l]=a.useState(null),[p,y]=a.useState({currentTarget:{},preventDefault:()=>{}}),v=a.useMemo(()=>t.map(e=>{var{id:r,sku:t,gtin:i,unitMultiplier:a,name:n,brand:o,isVariantOf:u,image:s,additionalProperty:c,offers:{offers:[{price:l,priceWithTaxes:d,listPrice:m,seller:p,quantity:y,listPriceWithTaxes:v}]}}=e;return{id:r,price:l,priceWithTaxes:d,listPrice:m,listPriceWithTaxes:v,seller:p,quantity:f===r?1:0,itemOffered:{sku:t,name:n,gtin:i,image:s,brand:o,isVariantOf:u,additionalProperty:c,unitMultiplier:a}}}).filter(e=>e.quantity>0),[t,f]),P=(0,u.Q)(v);return a.useEffect(()=>{f&&P.onClick(p)},[f,p]),useProductsSelected(r,s,function(e){c(e.products.map(e=>{var r=e.skuSpecifications.map(e=>({field:e.field.name,values:e.values.map(e=>e.name)}));return{slug:e.slug,sku:e.sku,name:e.name,gtin:e.gtin,id:e.id,unitMultiplier:e.unitMultiplier,brand:{name:e.brand.name,brandName:e.brand.name},isVariantOf:{productGroupID:e.isVariantOf.productGroupID,name:e.isVariantOf.name,skuVariants:e.isVariantOf.skuVariants},image:e.image,offers:{lowPrice:e.offers.lowPrice,lowPriceWithTaxes:e.offers.lowPriceWithTaxes,offers:e.offers.offers.map(e=>({availability:e.availability,price:e.price,listPrice:e.listPrice,listPriceWithTaxes:e.listPriceWithTaxes,priceWithTaxes:e.priceWithTaxes,quantity:e.quantity,seller:{identifier:e.seller.identifier}}))},additionalProperty:e.additionalProperty.map(e=>({propertyID:e.propertyID,name:e.name,value:e.value,valueReference:e.valueReference})),advertisement:e.advertisement,hasSpecifications:e.hasSpecifications,skuSpecifications:r}}))}),(0,d.jsx)(o.Z,function(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach(function(r){(0,i.Z)(e,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}({handleProductToBuy:l,setPendingEvent:y,sortOptions:[...m]},e))}},68687:function(e,r,t){t.d(r,{Q:function(){return useBuyButton}});var i=t(44194),a=t(16652),n=t(97358),o=t(71041),useBuyButton=function(e){var r,u=!(arguments.length>1)||void 0===arguments[1]||arguments[1],{openCart:s}=(0,a.l8)(),{currency:{code:c}}=(0,n.kP)(),f=Array.isArray(e);return{onClick:(0,i.useCallback)(r=>{if(r.preventDefault(),e){var i=f?e.reduce((e,r)=>e+=r.price*r.quantity,0):e.price*e.quantity;t.e(9399).then(t.bind(t,66393)).then(r=>{var{sendAnalyticsEvent:t}=r;t({name:"add_to_cart",params:{currency:c,value:i,items:f?e.map(generatedItem):[generatedItem(e)]}})}),f?e.forEach(e=>o.i8.addItem(e)):o.i8.addItem(e),u&&s()}function generatedItem(e){return{item_id:e.itemOffered.isVariantOf.productGroupID,item_name:e.itemOffered.isVariantOf.name,item_brand:e.itemOffered.brand.name,item_variant:e.itemOffered.sku,quantity:e.quantity,price:e.price,discount:e.listPrice-e.price,currency:c,item_variant_name:e.itemOffered.name,product_reference_id:e.itemOffered.gtin}}},[c,e,s,f]),"data-testid":"buy-button","data-sku":f?"sku-matrix-sidebar":null==e?void 0:e.itemOffered.sku,"data-seller":f?null===(r=e[0])||void 0===r?void 0:r.seller.identifier:null==e?void 0:e.seller.identifier}}}}]);