"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7245],{37245:function(t,e,n){n.r(e),n.d(e,{QuickBuyModalPresenter:function(){return to}});var o=n(95235),i=n(8529),r=n(2784),a=n(53055),s=n(60418),l=n(80131),c=n(68544),u=n(77316),d=n(97209),p=n(10013),b=n(27564),f=n(43897),v=n(35016),k=n(35246),g=n(8729),O=n(92491),y=n(48840),h=n(70554),m=n(52322);function x(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,o)}return n}function T(t){for(var e=1;e0&&(0,m.jsx)(h.oh,{children:(0,m.jsx)(k.$,{tags:o.tags})})]}):null},options:function(t){var e,n,o,i,r=t.product,a=t.quickBuyModalTheme,s=t.inStockComponent,l=t.selectedOptions,c=t.options,u=t.i18nText,d=t.setSelectedOptionsCallback,b=t.hideAsterixOnPDP;return(0,m.jsxs)("div",{style:{gridArea:v.p.OPTIONS},children:[(null==r||null===(e=r.subscriptionData)||void 0===e?void 0:e.displaySubscription)&&(0,m.jsx)(p.Y,T(T({},r.subscriptionData.subscriptionPurchaseOptions),{},{selectedOptions:l,onOptionChange:d})),!(null!=r&&null!==(n=r.subscriptionData)&&void 0!==n&&n.displaySubscriptionChoicesOnly)&&(0,m.jsx)(g.A,{options:c,selectedOptions:l,onOptionChange:d,hideAsterixOnPDP:b,i18nText:u,order:null===(o=a.productOptions)||void 0===o?void 0:o.order,dropdownWidth:null===(i=a.productOptions)||void 0===i||null===(i=i.dropdown)||void 0===i?void 0:i.width,showOnlyTwoRows:a.swatch.showOnlyTwoRows,displayColoursAsTextOnly:a.swatch.displayColoursAsTextOnly}),u.failedToAddToBasketError&&(0,m.jsx)(h.gY,{children:(0,m.jsx)(h.Vv,{error:u.failedToAddToBasketError,id:"quick-buy-add-to-basket-error-".concat(null==r?void 0:r.sku)})}),s&&s]})},pricing:function(t,e,n){var o;return(0,m.jsx)("div",{style:{gridArea:v.p.PRICING},children:(0,m.jsxs)(h.tw,{flexDirection:t.quickBuyModalTheme.pricing.flexDirection,alignItems:t.quickBuyModalTheme.pricing.alignItems,children:[t.pricing&&(0,m.jsx)(b.t,{pricing:t.pricing,priceDirection:t.quickBuyModalTheme.priceDirection,savings:t.quickBuyModalTheme.pricing.savings,i18nText:{saveLabel:t.i18nText.saveLabel,rrpLabel:t.i18nText.rrpLabel},priceTheme:t.quickBuyModalTheme.pricing.productPrice,discountMessageProps:{text:t.i18nText.subscriptionContractDiscountMessage,textStyle:null===(o=t.quickBuyModalTheme.pricing)||void 0===o||null===(o=o.discountMessage)||void 0===o?void 0:o.textStyle}}),!t.hideQuantitySelector&&(0,m.jsxs)("div",{style:{marginBottom:"".concat((0,y.W0)(2))},children:[(0,m.jsx)(h.Ds,{children:t.quantitySelector.i18nText.quantityLabel}),(0,m.jsx)(f.c,T(T({},t.quantitySelector),{},{quantityChangedCallback:function(t){t&&n(t)},editable:!0,quantity:e}))]})]})})},addToBag:function(t,e){var n,o,i,r,a,s,l=S({selectedQuantity:e,enablePreselectedProductVariant:t.enablePreselectedProductVariant,product:t.product,options:t.options,selectedOptions:t.selectedOptions}),c=(null===(n=t.product)||void 0===n||null===(n=n.subscriptionData)||void 0===n?void 0:n.enableSubscriptionContracts)&&(null===(o=t.product.subscriptionData.subscriptionPurchaseOptions)||void 0===o?void 0:o.activeTabIndex)===1&&!!t.product.subscriptionData.subscriptionPurchaseOptions.subscriptionContracts.length,u=(null===(i=t.product)||void 0===i||null===(i=i.subscriptionData)||void 0===i?void 0:i.enableSubscriptionContracts)&&((null===(r=t.product)||void 0===r||null===(r=r.subscriptionData)||void 0===r?void 0:r.productInBasketWithSubscriptionContract)||(null===(a=t.product)||void 0===a||null===(a=a.subscriptionData)||void 0===a?void 0:a.productInBasketWithoutSubscriptionContract)&&!!(null!==(s=t.product.subscriptionData.subscriptionPurchaseOptions)&&void 0!==s&&s.subscriptionContracts.length));return(0,m.jsx)(M,T({allowAddToBasket:!!l,allowAddToBasketAsSubscription:!!c,disableAddToBasketSubscriptions:!!u,selectedQuantity:e},t))},availability:function(t){return(0,m.jsx)("div",{style:{gridArea:v.p.AVAILABILITY},children:t.i18nText.availabilityMessage&&(0,m.jsx)(h.s,{children:t.i18nText.availabilityMessage})})},viewProduct:function(t){return(0,m.jsx)("div",{style:{gridArea:v.p.VIEWPRODUCT},children:t.links&&(0,m.jsx)(h.bi,{emphasis:"medium",href:t.links.productUrl,renderedAs:"a",onClick:function(e){var n;(null===(n=t.callbacks)||void 0===n?void 0:n.viewMoreInformationClicked)&&t.callbacks.viewMoreInformationClicked(e),t.setOpen&&t.setOpen(!1)},children:t.i18nText.viewMoreInformation})})}},M=function(t){return(0,m.jsx)("div",{style:{gridArea:v.p.ADDTOBAG},children:(0,m.jsx)(h.l1,{emphasis:"high",disabled:!t.allowAddToBasket||t.quantitySelector.maxValue<1||t.disableAddToBasketSubscriptions,onClick:function(){if(t.allowAddToBasket&&t.selectedQuantity&&t.selectedOptions){if(t.allowAddToBasketAsSubscription){var e;t.callbacks.addToBasketWithContractsCallback&&t.callbacks.addToBasketWithContractsCallback(t.selectedQuantity,null===(e=t.product)||void 0===e||null===(e=e.subscriptionData)||void 0===e||null===(e=e.subscriptionPurchaseOptions)||void 0===e?void 0:e.selectedFrequencyId)}else t.callbacks.addedToBasketClicked(t.selectedOptions,t.selectedQuantity)}},children:t.i18nText.addToBasket})})},P=function(t){var e=(0,O.G)();return(0,m.jsx)(h.OO,{children:t.components[e].map(function(e){return e?B[e](t.quickBuyModalContentProps,t.selectedQuantity,t.setSelectedQuantity):null})})},C=function(t){var e,n,o,i=(null===(e=t.subscriptionData)||void 0===e?void 0:e.productInBasketWithSubscriptionContract)||(null===(n=t.subscriptionData)||void 0===n?void 0:n.productInBasketWithoutSubscriptionContract)&&!!(null!==(o=t.subscriptionData)&&void 0!==o&&null!==(o=o.subscriptionPurchaseOptions)&&void 0!==o&&o.subscriptionContracts.length);return(0,m.jsxs)(r.Fragment,{children:[i&&(0,m.jsx)(h.o7,{text:t.i18nText.subscriptionInfoMessageText,type:"info"}),!t.quantitySelectorMaxValue&&(0,m.jsx)(h.tO,{type:"info",text:t.i18nText.maxQuantityBasketItemMessageText,"data-testid":"quantity-basket-item"})]})},w=function(t){return(0,m.jsxs)(h.Tc,{ref:t.modalButtonsRef,modalContentScrollable:t.modalContentScrollable,children:[(0,m.jsx)(h.l1,{emphasis:"high",disabled:!t.allowAddToBasket,onClick:function(){t.allowAddToBasket&&t.selectedQuantity&&t.selectedOptions&&t.callbacks.addedToBasketClicked(t.selectedOptions,t.selectedQuantity)},children:t.i18nText.addToBasket}),t.links&&!t.displayViewMoreInfo&&(0,m.jsx)(h.bi,{emphasis:"medium",href:t.links.productUrl,renderedAs:"a",onClick:function(){var e;(null===(e=t.callbacks)||void 0===e?void 0:e.viewMoreInformationClicked)&&t.callbacks.viewMoreInformationClicked,t.setOpen&&t.setOpen(!1)},children:t.i18nText.viewMoreInformation})]})},j=function(t){var e,n,o=t.i18nText,a=t.product,s=t.options,l=t.pricing,c=t.links,u=t.quantitySelector,p=t.hideQuantitySelector,b=t.callbacks,f=t.quickBuyModalTheme,v=t.coreTheme,k=t.setOpen,g=t.inStockComponent,O=t.selectedOptions,y=t.setSelectedOptionsCallback,x=t.enablePreselectedProductVariant,T=t.displayViewMoreInfo,B=t.hideAsterixOnPDP,M=r.useState(1),j=(0,i.Z)(M,2),A=j[0],I=j[1],D=r.useState(!1),q=(0,i.Z)(D,2),V=q[0],L=q[1],Q=r.useRef(null),E=r.useRef(null);if(r.useEffect(function(){var t;if(null!=Q&&Q.current&&null!=E&&E.current)return(t=new d.Z(function(){var t,e,n=null==Q||null===(t=Q.current)||void 0===t?void 0:t.getBoundingClientRect(),o=null==E||null===(e=E.current)||void 0===e?void 0:e.getBoundingClientRect();n&&o&&L(n.top+n.height>o.top)})).observe(Q.current),function(){t&&t.disconnect()}},[Q]),!a)return(0,m.jsx)(h.eZ,{flashMessageId:"quickBuyModalMissingProduct",message:o.missingProductMessage,type:"error"});var R=S({enablePreselectedProductVariant:x,product:a,selectedQuantity:A,options:s,selectedOptions:O});return(0,m.jsxs)(r.Fragment,{children:[(0,m.jsx)(h.r6,{children:o.modalTitle}),(0,m.jsx)(C,{i18nText:{subscriptionInfoMessageText:o.subscriptionInfoMessageText,maxQuantityBasketItemMessageText:o.maxQuantityBasketItemMessageText,failedToAddToBasketError:o.failedToAddToBasketError},productSku:a.sku,subscriptionData:a.subscriptionData,quantitySelectorMaxValue:u.maxValue}),(0,m.jsxs)(h.uE,{ref:Q,reducedBottomPadding:f.enableStickyFooterButtons,children:[(0,m.jsx)(h.W7,{urls:a.images[0],alt:a.title,width:(null===(e=f.product)||void 0===e||null===(e=e.image)||void 0===e?void 0:e.width)||["100%","100%",190,191],height:(null===(n=f.product)||void 0===n||null===(n=n.image)||void 0===n?void 0:n.height)||["","",190,191]}),(0,m.jsx)(P,{quickBuyModalContentProps:{i18nText:o,product:a,pricing:l,links:c,quantitySelector:u,hideQuantitySelector:p,callbacks:b,quickBuyModalTheme:f,coreTheme:v,inStockComponent:g,options:s,selectedOptions:O,setSelectedOptionsCallback:y,setOpen:k,enablePreselectedProductVariant:x,hideAsterixOnPDP:B,productSku:null==a?void 0:a.sku.toString()},components:f.enabledComponents,selectedQuantity:A,setSelectedQuantity:I})]}),f.enableStickyFooterButtons&&(0,m.jsx)(w,{i18nText:o,modalButtonsRef:E,modalContentScrollable:V,allowAddToBasket:!!R,selectedQuantity:A,selectedOptions:O,callbacks:b,links:c,displayViewMoreInfo:T})]})},A=n(61265);function I(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,o)}return n}function D(t){for(var e=1;e1?tQ.multipleItemsText:tQ.singleItemText,[(null==ts?void 0:ts.maxPerOrder)||5e3,tC]),tR=r.useRef(!1),tN=r.useRef(),tZ=r.useRef(),tW=r.useRef(),t_=r.useRef();if(S.presentAuroraQuickBuyModal.current=function(t){var e,n=t.sku,o=t.quantity,i=t.fromRecommendations,r=t.onBasketChangeBeacon,a=t.trackingUrl,l=t.initialSelectedOptions,c=t.setSelectedOptionsCallback,u=t.setSelectedVariantCallback,d=t.setOptionsCallback,p=t.fullProductData,f=t.displayNotifyWhenInStock,v=t.enableMobilePDPStickyAddToBasket;if(!l){tj();return}tO.current=o,tR.current=null!=i&&i,tZ.current=r,tW.current=a,tN.current=v,tk(l),t_.current={setSelectedOptionsCallback:c,setSelectedVariantCallback:u,setOptionsCallback:d};var k=p?"/e2/operation/product/product-options/".concat(n):"/e2/operation/product-options/".concat(n,"?displayNotifyWhenInStock=").concat(f);l&&s.Z.get(k,{timeout:null!==(e=null==x?void 0:x.PRODUCT_OPTIONS_TIMEOUT)&&void 0!==e?e:5e3,headers:{"Accept-Encoding":"deflate, gzip, br",Host:b,"x-customer-location":h}}).then(function(t){return t.data}).then(function(t){var e=Object.values(l).reduce(function(t,e){return t[e]},t);if(!e){tj();return}tl(e.variant),tp(e.options),tg.current=t}).catch(function(t){console.trace("Error fetching product options: ".concat(k),t),tj()}),ti(!0)},!S.presentAuroraQuickBuyModal)return t.warn("AuroraQuickBuyModalPresenter: Failed to find an initialised BasketContext. Make sure presentAuroraQuickBuyModal ref is defined and it wraps AuroraQuickBuyModalPresenter."),null;if(!to)return null;var tF=C.patterns.quickBuyModal;return(0,m.jsx)(q,tn({enablePreselectedProductVariant:d,loading:!td.length,setOpen:ti,hideAsterixOnPDP:u,options:td,product:ts,quickBuyModalTheme:tF,displayViewMoreInfo:!!tN,coreTheme:w,rendering:{open:to,onClose:function(){ti(!1),X.t.modalClose((null==ts?void 0:ts.sku.toString())||"")}},i18nText:tn(tn({},tI),{},{maxQuantityBasketItemMessageText:tE,subscriptionInfoMessageText:"",subscriptionContractDiscountMessage:"",failedToAddToBasketError:tm?tq:void 0,availabilityMessage:null==ts?void 0:ts.availabilityMessage}),modal:{i18nText:tV,showHeader:!0,stickyHeader:!0,headerOffset:T,gridColSpan:[12,8,8,6],"data-testid":"quick-buy-modal",animation:C.patterns.quickBuyModal.animation},selectedOptions:tv,setSelectedOptionsCallback:function(t,e){if(!tg.current){tj();return}tx(!1);var n=(0,U.WZ)({selectedOptions:tv,selectedVariant:ts,optionKey:t,value:e,productOptionsMap:tg.current,setSelectedOptionsCallback:tk,setSelectedVariantCallback:tl,setOptionsCallback:tp}),o=n.updatedSelectedOptions,i=n.updatedProductOptions;t_.current&&o&&i&&(t_.current.setSelectedOptionsCallback&&t_.current.setSelectedOptionsCallback(o),t_.current.setSelectedVariantCallback&&t_.current.setSelectedVariantCallback(i.variant),t_.current.setOptionsCallback&&t_.current.setOptionsCallback(i.options))},pricing:ts?(0,G.a)(ts,f,v):void 0,links:{productUrl:null==ts?void 0:ts.product.url},callbacks:{addedToBasketClicked:function(t,e){if(S.presentAddedToBasketModal&&ts){if(!ts.enableAddToBasket){tx(!0);return}var n=S.presentAddedToBasketModal.current;S.presentAddedToBasketModal.current=function(t,e){S.presentAddedToBasketModal&&(ti(!1),tx(!1),n(t,e),S.presentAddedToBasketModal.current=n)},tB([{quantity:e,sku:ts.sku.toString()}],{fromRecommendations:tR.current,location:J.A.PRODUCT_LIST},_.eN.HomeDelivery,void 0,tZ.current,tW.current),X.t.modalAddToBasket(ts.sku.toString())}},viewMoreInformationClicked:function(){ts&&X.t.modalInformation(null==ts?void 0:ts.product.sku.toString())},addToBasketWithContractsCallback:function(t,e){tS({variables:{basketId:null==P?void 0:P.id,sku:null==ts?void 0:ts.sku.toString(),quantity:t,contractId:e,settings:{currency:g,shippingDestination:O.code}}}).then(function(){if(S.presentAddedToBasketModal&&ts){var e=S.presentAddedToBasketModal.current;ti(!1),e(null==ts?void 0:ts.sku.toString(),t)}})}},quantitySelector:{i18nText:tL,maxValue:tP,quantity:tO.current}},n&&o&&{inStockComponent:(0,m.jsx)(c.G,{selectedVariant:ts,url:(null==ts?void 0:ts.product.url)||"",styleOverride:{margin:{top:0,bottom:2}}})}))}},71663:function(t,e,n){n.d(e,{L:function(){return o}});var o="unselected"},90576:function(t,e,n){n.d(e,{WZ:function(){return u},fH:function(){return c},tj:function(){return a}});var o,i=n(8529),r=n(71663),a=function(t,e,n){return t.reduce(function(t,o){if(!t.currentMap){var i=n[e[o]];return t.currentMap=i,null!=i&&i.options&&(t.productOptions=i),t}var r=t.currentMap[e[o]];return t.currentMap&&null!=r&&r.options?t.productOptions=r:t.currentMap=r,t},{productOptions:null,currentMap:null}).productOptions},s=function(t){var e=t.selectedOptions,n=t.productOptionsMap;return Object.values(e).reduce(function(t,e){if(!n)return t;if(!t.currentMap){var o=n[e];return t.currentMap=o,null!=o&&o.options&&(t.productOptions=o),t}var i=t.currentMap[e];return t.currentMap&&null!=i&&i.options?t.productOptions=i:t.currentMap=i,t},{productOptions:null,currentMap:null}).productOptions},l=((o=l||{}).THUMBNAIL="THUMBNAIL",o.ORIGINAL="ORIGINAL",o.MAGNIFY="MAGNIFY",o),c=function(t){var e,n=null===(e=t.personalisationData)||void 0===e?void 0:e.personalisationSupportImages;if(n){var o=[];return n.forEach(function(e){var n;null===(n=e.supportImages)||void 0===n||null===(n=n.imagesWithAssetSets)||void 0===n||n.forEach(function(e){var n,i,r,a=e.assetSet,s=e.images,c={url:s.find(function(t){return t.size===l.THUMBNAIL}).url,alt:(null==t?void 0:t.title)||""},u={url:s.find(function(t){return t.size===l.ORIGINAL}).url,alt:(null==t?void 0:t.title)||""},d={url:s.find(function(t){return t.size===l.MAGNIFY}).url,alt:(null==t?void 0:t.title)||""},p=o.find(function(t){return t.key===a}),b=p?o.indexOf(p):0;p||(o.push({key:a,images:[],thumbnails:[],zoom:[]}),b=o.length-1),null===(n=o[b])||void 0===n||n.images.push(u),null===(i=o[b])||void 0===i||i.thumbnails.push(c),null===(r=o[b])||void 0===r||r.zoom.push(d)})}),o}},u=function(t){var e,n=t.productOptionsMap,o=t.selectedOptions,a=t.setSelectedOptionsCallback,l=t.setOptionsCallback,c=t.setSelectedVariantCallback,u=t.selectedVariant,d=t.optionKey,p=t.value;o[d]=p,a(o);var b=s({selectedOptions:o,productOptionsMap:n});if(b)return l(b.options),c(b.variant),{updatedSelectedOptions:o,updatedProductOptions:b};if(null!=u&&null!==(e=u.product)&&void 0!==e&&e.linkedOn){var f=Object.entries(o).reduce(function(t,e){var n,o=(0,i.Z)(e,2),a=o[0],s=o[1];return a===(null===(n=u.product)||void 0===n?void 0:n.linkedOn)?t[a]=s:t[a]=r.L,t},{}),v=s({productOptionsMap:n,selectedOptions:f});if(v)return l(v.options),c(v.variant),{updatedSelectedOptions:f,updatedProductOptions:v}}return{updatedSelectedOptions:null,updatedProductOptions:null}}}}]); //# sourceMappingURL=7245.7237a1958a91bd07.js.map