"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1662],{41662:function(e,t,o){o.r(t),o.d(t,{QuickBuyModalPresenter:function(){return eB}});var n,i,r=o(95235),a=o(8529),l=o(2784),s=o(53055),c=o(60418),u=o(80131),d=o(68544),p=o(77316),b=o(97209),h=o(10013),y=o(27564),v=o(43897),g=o(35016),f=o(35246),k=o(69363),O=o(15792),x=o(16048),m=o(31477),w=o(17258),T=o(78930),S=o(93479),C=o(31275),P=o(73557),j=o(7328),B=o(48840),D=(0,B.zo)(x.a)(i||(i=(0,j.Z)(["\n width: 100%;\n"]))),A=o(52322);function M(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),o.push.apply(o,n)}return o}function I(e){for(var t=1;t0||e.index>=0,selected:null===(o=e.selectedOptions)||void 0===o?void 0:o[e.option.key],maxDropdownHeight:e.maxDropdownHeight||"146px",width:e.dropdownWidth},e.option.label===q.Size&&{customErrorMessage:e.customErrorMessage}),{},{hideAsterixOnPDP:e.hideAsterixOnPDP}))},L=function(e){var t,o,n,i,r=e.choicesWithColour,a=(0,O.Fg)();return r.length>0&&!e.forceDropDowns&&(null===(t=null===(o=e.swatch)||void 0===o?void 0:o.show)||void 0===t||t)?(0,A.jsx)(w.m,{shape:null!==(n=e.swatchShape)&&void 0!==n?n:a.patterns.productBlock.components.quickBuySwatchShape,colours:r,selectedColour:null===(i=e.selectedOptions)||void 0===i?void 0:i[e.option.key],onColourChange:function(t){var o;e.onOptionChange(e.option.key,t),null===(o=e.onColourSwatchClick)||void 0===o||o.call(e)},i18nText:e.i18nText.swatch,showOnlyTwoRows:e.showOnlyTwoRows,displayColoursAsTextOnly:e.displayColoursAsTextOnly,size:a.patterns.productBlock.components.swatch.productOptionSize,noSwatchBorder:a.patterns.productBlock.components.swatch.noBorder}):null},Q=function(e){var t,o=e.choicesWithColour;return(0,A.jsx)(T.k,{textStyle:e.textStyle,label:e.option.localizedKey||e.option.label,labelHidden:e.hideDropDownsLabel||!1,required:!1,ariaLabel:e.option.label,images:o,selectedImage:null===(t=e.selectedOptions)||void 0===t?void 0:t[e.option.key],onImageChange:function(t){var o;e.onOptionChange(e.option.key,t),null===(o=e.onColourSwatchClick)||void 0===o||o.call(e)},i18nText:e.i18nText.imageSwatch,hideOptionalText:!0,displayColoursAsTextOnly:e.displayColoursAsTextOnly,showAllImageSwatches:e.showAllImageSwatches})},R=function(e,t){var o;return I(I({},t&&{error:null===(o=e.customErrorMessage)||void 0===o?void 0:o.errorMessage}),{},{labelCustomComponent:e.option.attribute?(0,A.jsx)("div",{style:{display:"flex",justifyContent:"flex-end",width:"100%"},children:e.labelCustomComponent}):null})},W=function(e,t){var o=t.choices.find(function(t){return t.key===e});return(null==o?void 0:o.displayText)||e},Z=function(e,t,o,n){var i,r="unselected"===t||!!e.option.valueHidden;return(0,A.jsx)(S.Ee,I(I({required:null===(i=e.required)||void 0===i||i,label:E(e),textStyle:e.textStyle,selectedValue:o,labelHidden:!1,valueHidden:r,columns:2,getState:function(t){return e.onOptionChange(e.option.key,t)},horizontal:!0,defaultValue:o},R(e,n)),{},{hideAsterixOnPDP:e.hideAsterixOnPDP,showBrandNameBeforeSize:e.showBrandNameBeforeSize,brandName:e.brandName,children:e.option.choices.map(function(t,o){return(0,A.jsx)(C.X,{name:e.option.key,title:t.title,value:t.key,disabled:!0!==e.enableOOSAddtoWishlist&&t.disabled,useDisabledStyling:t.useDisabledStyling,borderWidth:"2px"},o)})}))},_=function(e){var t,o,n,i=e.option.choices.filter(function(e){return e.colour}),r=null===(t=e.selectedOptions)||void 0===t?void 0:t[e.option.key],a=W(r,e.option),s=e.option.label===q.Size&&(null===(o=e.customErrorMessage)||void 0===o?void 0:o.displayError),c=(0,A.jsx)(m.N,{required:!e.hideAsterixOnPDP,textStyle:e.textStyle,children:e.showVariantNameNextTocolorLabel?"".concat(E(e)).concat(a?": ".concat(a):""):E(e)});switch(e.option.type){case q.Dropdown:return(0,A.jsxs)(l.Fragment,{children:[e.disableColorDropdown?c:(0,A.jsx)(V,I(I({},e),{},{choicesWithColour:i})),(0,A.jsx)(L,I(I({},e),{},{choicesWithColour:i}))]});case q.Image:return(0,A.jsx)(Q,I(I({},e),{},{choicesWithColour:i}));case q.Swatch:return(0,A.jsxs)(l.Fragment,{children:[c,(0,A.jsx)(w.m,{shape:null!==(n=e.swatchShape)&&void 0!==n?n:P.M.SQUARE,colours:i,selectedColour:r,onColourChange:function(t){var o;e.onOptionChange(e.option.key,t),null===(o=e.onColourSwatchClick)||void 0===o||o.call(e)},i18nText:e.i18nText.swatch,showOnlyTwoRows:e.showOnlyTwoRows,displayColoursAsTextOnly:e.displayColoursAsTextOnly})]});default:return Z(e,r,a,s)}},N=o(37218);function H(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),o.push.apply(o,n)}return o}function z(e){for(var t=1;t0&&(0,A.jsx)(G.oh,{children:(0,A.jsx)(f.$,{tags:n.tags})})]}):null},options:function(e){var t,o,n,i,r=e.product,a=e.quickBuyModalTheme,l=e.inStockComponent,s=e.selectedOptions,c=e.options,u=e.i18nText,d=e.setSelectedOptionsCallback,p=e.hideAsterixOnPDP;return(0,A.jsxs)("div",{style:{gridArea:g.p.OPTIONS},children:[(null==r||null===(t=r.subscriptionData)||void 0===t?void 0:t.displaySubscription)&&(0,A.jsx)(h.Y,Y(Y({},r.subscriptionData.subscriptionPurchaseOptions),{},{selectedOptions:s,onOptionChange:d})),!(null!=r&&null!==(o=r.subscriptionData)&&void 0!==o&&o.displaySubscriptionChoicesOnly)&&(0,A.jsx)(F,{options:c,selectedOptions:s,onOptionChange:d,hideAsterixOnPDP:p,i18nText:u,order:null===(n=a.productOptions)||void 0===n?void 0:n.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,A.jsx)(G.gY,{children:(0,A.jsx)(G.Vv,{error:u.failedToAddToBasketError,id:"quick-buy-add-to-basket-error-".concat(null==r?void 0:r.sku)})}),l&&l]})},pricing:function(e,t,o){var n;return(0,A.jsx)("div",{style:{gridArea:g.p.PRICING},children:(0,A.jsxs)(G.tw,{flexDirection:e.quickBuyModalTheme.pricing.flexDirection,alignItems:e.quickBuyModalTheme.pricing.alignItems,children:[e.pricing&&(0,A.jsx)(y.t,{pricing:e.pricing,priceDirection:e.quickBuyModalTheme.priceDirection,savings:e.quickBuyModalTheme.pricing.savings,i18nText:{saveLabel:e.i18nText.saveLabel,rrpLabel:e.i18nText.rrpLabel},priceTheme:e.quickBuyModalTheme.pricing.productPrice,discountMessageProps:{text:e.i18nText.subscriptionContractDiscountMessage,textStyle:null===(n=e.quickBuyModalTheme.pricing)||void 0===n||null===(n=n.discountMessage)||void 0===n?void 0:n.textStyle}}),!e.hideQuantitySelector&&(0,A.jsxs)("div",{style:{marginBottom:"".concat((0,B.W0)(2))},children:[(0,A.jsx)(G.Ds,{children:e.quantitySelector.i18nText.quantityLabel}),(0,A.jsx)(v.c,Y(Y({},e.quantitySelector),{},{quantityChangedCallback:function(e){e&&o(e)},editable:!0,quantity:t}))]})]})})},addToBag:function(e,t){var o,n,i,r,a,l,s=J({selectedQuantity:t,enablePreselectedProductVariant:e.enablePreselectedProductVariant,product:e.product,options:e.options,selectedOptions:e.selectedOptions}),c=(null===(o=e.product)||void 0===o||null===(o=o.subscriptionData)||void 0===o?void 0:o.enableSubscriptionContracts)&&(null===(n=e.product.subscriptionData.subscriptionPurchaseOptions)||void 0===n?void 0:n.activeTabIndex)===1&&!!e.product.subscriptionData.subscriptionPurchaseOptions.subscriptionContracts.length,u=(null===(i=e.product)||void 0===i||null===(i=i.subscriptionData)||void 0===i?void 0:i.enableSubscriptionContracts)&&((null===(r=e.product)||void 0===r||null===(r=r.subscriptionData)||void 0===r?void 0:r.productInBasketWithSubscriptionContract)||(null===(a=e.product)||void 0===a||null===(a=a.subscriptionData)||void 0===a?void 0:a.productInBasketWithoutSubscriptionContract)&&!!(null!==(l=e.product.subscriptionData.subscriptionPurchaseOptions)&&void 0!==l&&l.subscriptionContracts.length));return(0,A.jsx)($,Y({allowAddToBasket:!!s,allowAddToBasketAsSubscription:!!c,disableAddToBasketSubscriptions:!!u,selectedQuantity:t},e))},availability:function(e){return(0,A.jsx)("div",{style:{gridArea:g.p.AVAILABILITY},children:e.i18nText.availabilityMessage&&(0,A.jsx)(G.s,{children:e.i18nText.availabilityMessage})})},viewProduct:function(e){return(0,A.jsx)("div",{style:{gridArea:g.p.VIEWPRODUCT},children:e.links&&(0,A.jsx)(G.bi,{emphasis:"medium",href:e.links.productUrl,renderedAs:"a",onClick:function(t){var o;(null===(o=e.callbacks)||void 0===o?void 0:o.viewMoreInformationClicked)&&e.callbacks.viewMoreInformationClicked(t),e.setOpen&&e.setOpen(!1)},children:e.i18nText.viewMoreInformation})})}},$=function(e){return(0,A.jsx)("div",{style:{gridArea:g.p.ADDTOBAG},children:(0,A.jsx)(G.l1,{emphasis:"high",disabled:!e.allowAddToBasket||e.quantitySelector.maxValue<1||e.disableAddToBasketSubscriptions,onClick:function(){if(e.allowAddToBasket&&e.selectedQuantity&&e.selectedOptions){if(e.allowAddToBasketAsSubscription){var t;e.callbacks.addToBasketWithContractsCallback&&e.callbacks.addToBasketWithContractsCallback(e.selectedQuantity,null===(t=e.product)||void 0===t||null===(t=t.subscriptionData)||void 0===t||null===(t=t.subscriptionPurchaseOptions)||void 0===t?void 0:t.selectedFrequencyId)}else e.callbacks.addedToBasketClicked(e.selectedOptions,e.selectedQuantity)}},children:e.i18nText.addToBasket})})},ee=function(e){var t=(0,U.G)();return(0,A.jsx)(G.OO,{children:e.components[t].map(function(t){return t?X[t](e.quickBuyModalContentProps,e.selectedQuantity,e.setSelectedQuantity):null})})},et=function(e){var t,o,n,i=(null===(t=e.subscriptionData)||void 0===t?void 0:t.productInBasketWithSubscriptionContract)||(null===(o=e.subscriptionData)||void 0===o?void 0:o.productInBasketWithoutSubscriptionContract)&&!!(null!==(n=e.subscriptionData)&&void 0!==n&&null!==(n=n.subscriptionPurchaseOptions)&&void 0!==n&&n.subscriptionContracts.length);return(0,A.jsxs)(l.Fragment,{children:[i&&(0,A.jsx)(G.o7,{text:e.i18nText.subscriptionInfoMessageText,type:"info"}),!e.quantitySelectorMaxValue&&(0,A.jsx)(G.tO,{type:"info",text:e.i18nText.maxQuantityBasketItemMessageText,"data-testid":"quantity-basket-item"})]})},eo=function(e){return(0,A.jsxs)(G.Tc,{ref:e.modalButtonsRef,modalContentScrollable:e.modalContentScrollable,children:[(0,A.jsx)(G.l1,{emphasis:"high",disabled:!e.allowAddToBasket,onClick:function(){e.allowAddToBasket&&e.selectedQuantity&&e.selectedOptions&&e.callbacks.addedToBasketClicked(e.selectedOptions,e.selectedQuantity)},children:e.i18nText.addToBasket}),e.links&&!e.displayViewMoreInfo&&(0,A.jsx)(G.bi,{emphasis:"medium",href:e.links.productUrl,renderedAs:"a",onClick:function(){var t;(null===(t=e.callbacks)||void 0===t?void 0:t.viewMoreInformationClicked)&&e.callbacks.viewMoreInformationClicked,e.setOpen&&e.setOpen(!1)},children:e.i18nText.viewMoreInformation})]})},en=function(e){var t,o,n=e.i18nText,i=e.product,r=e.options,s=e.pricing,c=e.links,u=e.quantitySelector,d=e.hideQuantitySelector,p=e.callbacks,h=e.quickBuyModalTheme,y=e.coreTheme,v=e.setOpen,g=e.inStockComponent,f=e.selectedOptions,k=e.setSelectedOptionsCallback,O=e.enablePreselectedProductVariant,x=e.displayViewMoreInfo,m=e.hideAsterixOnPDP,w=l.useState(1),T=(0,a.Z)(w,2),S=T[0],C=T[1],P=l.useState(!1),j=(0,a.Z)(P,2),B=j[0],D=j[1],M=l.useRef(null),I=l.useRef(null);if(l.useEffect(function(){var e;if(null!=M&&M.current&&null!=I&&I.current)return(e=new b.Z(function(){var e,t,o=null==M||null===(e=M.current)||void 0===e?void 0:e.getBoundingClientRect(),n=null==I||null===(t=I.current)||void 0===t?void 0:t.getBoundingClientRect();o&&n&&D(o.top+o.height>n.top)})).observe(M.current),function(){e&&e.disconnect()}},[M]),!i)return(0,A.jsx)(G.eZ,{flashMessageId:"quickBuyModalMissingProduct",message:n.missingProductMessage,type:"error"});var q=J({enablePreselectedProductVariant:O,product:i,selectedQuantity:S,options:r,selectedOptions:f});return(0,A.jsxs)(l.Fragment,{children:[(0,A.jsx)(G.r6,{children:n.modalTitle}),(0,A.jsx)(et,{i18nText:{subscriptionInfoMessageText:n.subscriptionInfoMessageText,maxQuantityBasketItemMessageText:n.maxQuantityBasketItemMessageText,failedToAddToBasketError:n.failedToAddToBasketError},productSku:i.sku,subscriptionData:i.subscriptionData,quantitySelectorMaxValue:u.maxValue}),(0,A.jsxs)(G.uE,{ref:M,reducedBottomPadding:h.enableStickyFooterButtons,children:[(0,A.jsx)(G.W7,{urls:i.images[0],alt:i.title,width:(null===(t=h.product)||void 0===t||null===(t=t.image)||void 0===t?void 0:t.width)||["100%","100%",190,191],height:(null===(o=h.product)||void 0===o||null===(o=o.image)||void 0===o?void 0:o.height)||["","",190,191]}),(0,A.jsx)(ee,{quickBuyModalContentProps:{i18nText:n,product:i,pricing:s,links:c,quantitySelector:u,hideQuantitySelector:d,callbacks:p,quickBuyModalTheme:h,coreTheme:y,inStockComponent:g,options:r,selectedOptions:f,setSelectedOptionsCallback:k,setOpen:v,enablePreselectedProductVariant:O,hideAsterixOnPDP:m,productSku:null==i?void 0:i.sku.toString()},components:h.enabledComponents,selectedQuantity:S,setSelectedQuantity:C})]}),h.enableStickyFooterButtons&&(0,A.jsx)(eo,{i18nText:n,modalButtonsRef:I,modalContentScrollable:B,allowAddToBasket:!!q,selectedQuantity:S,selectedOptions:f,callbacks:p,links:c,displayViewMoreInfo:x})]})},ei=o(61265);function er(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),o.push.apply(o,n)}return o}function ea(e){for(var t=1;t1?eQ.multipleItemsText:eQ.singleItemText,[(null==Z?void 0:Z.maxPerOrder)||5e3,eB]),eW=l.useRef(!1),eZ=l.useRef(),e_=l.useRef(),eN=l.useRef(),eH=l.useRef();if(S.presentAuroraQuickBuyModal.current=function(e){var t,o=e.sku,n=e.quantity,i=e.fromRecommendations,r=e.onBasketChangeBeacon,a=e.trackingUrl,l=e.initialSelectedOptions,s=e.setSelectedOptionsCallback,u=e.setSelectedVariantCallback,d=e.setOptionsCallback,p=e.fullProductData,h=e.displayNotifyWhenInStock,y=e.enableMobilePDPStickyAddToBasket;if(!l){eA();return}X.current=n,eW.current=null!=i&&i,e_.current=r,eN.current=a,eZ.current=y,Y(l),eH.current={setSelectedOptionsCallback:s,setSelectedVariantCallback:u,setOptionsCallback:d};var v=p?"/e2/operation/product/product-options/".concat(o):"/e2/operation/product-options/".concat(o,"?displayNotifyWhenInStock=").concat(h);l&&c.Z.get(v,{timeout:null!==(t=null==m?void 0:m.PRODUCT_OPTIONS_TIMEOUT)&&void 0!==t?t:5e3,headers:{"Accept-Encoding":"deflate, gzip, br",Host:b,"x-customer-location":x}}).then(function(e){return e.data}).then(function(e){var t=Object.values(l).reduce(function(e,t){return e[t]},e);if(!t){eA();return}_(t.variant),F(t.options),J.current=e}).catch(function(e){console.trace("Error fetching product options: ".concat(v),e),eA()}),Q(!0)},!S.presentAuroraQuickBuyModal)return e.warn("AuroraQuickBuyModalPresenter: Failed to find an initialised BasketContext. Make sure presentAuroraQuickBuyModal ref is defined and it wraps AuroraQuickBuyModalPresenter."),null;if(!L)return null;var ez=B.patterns.quickBuyModal,eF="v1|round_quick_buy_button"===w.quick_buy_icon_button;return(0,A.jsx)(el,ej({enablePreselectedProductVariant:r,loading:!z.length,setOpen:Q,hideAsterixOnPDP:i,options:z,product:Z,quickBuyModalTheme:ez,displayViewMoreInfo:!!eZ,coreTheme:D,rendering:{open:L,onClose:function(){Q(!1),eS.t.modalClose((null==Z?void 0:Z.sku.toString())||"")}},i18nText:ej(ej({},eI),{},{maxQuantityBasketItemMessageText:eR,subscriptionInfoMessageText:"",subscriptionContractDiscountMessage:"",failedToAddToBasketError:et?eE:void 0,availabilityMessage:null==Z?void 0:Z.availabilityMessage}),modal:{i18nText:eV,showHeader:!0,stickyHeader:!0,headerOffset:T,gridColSpan:[12,8,8,6],"data-testid":"quick-buy-modal",animation:!!eF||B.patterns.quickBuyModal.animation},selectedOptions:K,setSelectedOptionsCallback:function(e,t){if(!J.current){eA();return}eo(!1);var o=(0,ef.WZ)({selectedOptions:K,selectedVariant:Z,optionKey:e,value:t,productOptionsMap:J.current,setSelectedOptionsCallback:Y,setSelectedVariantCallback:_,setOptionsCallback:F}),n=o.updatedSelectedOptions,i=o.updatedProductOptions;eH.current&&n&&i&&(eH.current.setSelectedOptionsCallback&&eH.current.setSelectedOptionsCallback(n),eH.current.setSelectedVariantCallback&&eH.current.setSelectedVariantCallback(i.variant),eH.current.setOptionsCallback&&eH.current.setOptionsCallback(i.options))},pricing:Z?(0,ek.a)(Z,h,y):void 0,links:{productUrl:null==Z?void 0:Z.product.url},callbacks:{addedToBasketClicked:function(e,t){if(S.presentAddedToBasketModal&&Z){if(!Z.enableAddToBasket){eo(!0);return}var o=S.presentAddedToBasketModal.current;S.presentAddedToBasketModal.current=function(e,t){S.presentAddedToBasketModal&&(Q(!1),eo(!1),o(e,t),S.presentAddedToBasketModal.current=o)},er([{quantity:t,sku:Z.sku.toString()}],{fromRecommendations:eW.current,location:ew.A.PRODUCT_LIST},ev.eN.HomeDelivery,void 0,e_.current,eN.current),eS.t.modalAddToBasket(Z.sku.toString())}},viewMoreInformationClicked:function(){Z&&eS.t.modalInformation(null==Z?void 0:Z.product.sku.toString())},addToBasketWithContractsCallback:function(e,t){ei({variables:{basketId:null==j?void 0:j.id,sku:null==Z?void 0:Z.sku.toString(),quantity:e,contractId:t,settings:{currency:g,shippingDestination:f.code}}}).then(function(){if(S.presentAddedToBasketModal&&Z){var t=S.presentAddedToBasketModal.current;Q(!1),t(null==Z?void 0:Z.sku.toString(),e)}})}},quantitySelector:{i18nText:eL,maxValue:eP,quantity:X.current}},o&&n&&{inStockComponent:(0,A.jsx)(d.G,{selectedVariant:Z,url:(null==Z?void 0:Z.product.url)||"",styleOverride:{margin:{top:0,bottom:2}}})}))}}}]); //# sourceMappingURL=1662.2d268404e30c8d09.js.map