(window.webpackJsonp=window.webpackJsonp||[]).push([[8],{"1SpI":function(e,t,r){"use strict";r.r(t);r("LR6M"),r("y/s1"),r("oLpx");var a=r("cDcd"),s=r("Hxoz"),n=r("hBpL");class i extends a.Component{constructor(e,t){super(e),this._onInputChange=e=>{const t=""===e.target.value?"":this.state.error;this.setState({promoCodeInputValue:e.target.value,error:t,canApply:!!e.target.value})},this._applyPromotion=e=>{if(!e||!e.cart)return;const t=this.state.promoCodeInputValue;e.addPromoCode({promoCode:t}).then(e=>{"SUCCESS"===e.status?this.setState({promoCodeInputValue:"",error:"",canApply:!1}):"ALREADYADDED"===e.substatus?this.setState({error:this.props.duplicatePromoCodeErrorText}):this.setState({error:this.props.invalidPromoCodeErrorText})}).catch(e=>{this.setState({error:this.props.failedToAddPromoCodeErrorText})})},this._renderForm=(e,t,r)=>{const n=Object(s.getTelemetryAttributes)(this.props.telemetryContent,this.payLoad);return a.createElement("form",{onSubmit:e=>{e.preventDefault(),this._applyPromotion(r)},className:"msc-promo-code__form-container"},a.createElement("div",{className:"msc-promo-code__group"},a.createElement("input",{className:"msc-promo-code__input-box","aria-label":e,onChange:this._onInputChange,value:this.state.promoCodeInputValue,placeholder:e}),a.createElement(s.Button,Object.assign({title:t,className:"msc-promo-code__apply-btn btn",onClick:e=>{this._applyPromotion(r)},disabled:!this.state.canApply},n),t)))},this._removePromotion=(e,t)=>{if(!e)return;const r=t.currentTarget.getAttribute("data-value")||"";e.removePromoCodes({promoCodes:[r]}).then(e=>{"SUCCESS"===e.status&&this.setState({error:""})}).catch(()=>{this.setState({error:this.props.failedToRemovePromoCodeErrorText})})},this._calculateDiscount=(e,t)=>{if(!(t&&t.cart&&t.cart.CartLines&&0!==t.cart.CartLines.length&&e))return;let r=0;for(const a of t.cart.CartLines)if(a.DiscountLines)for(const t of a.DiscountLines)t.DiscountCode===e&&(r+=t.DiscountCost);return-1*r},this._renderAppliedPromoCode=e=>{if(!(e.cart&&e.cart.cart&&e.cart.cart.Coupons&&e.cart.cart.Coupons.length>0))return;const t=t=>{this._removePromotion(e.cart,t)},r=e.cart.cart.Coupons.reduce((t,r)=>t+(this._calculateDiscount(r.Code||"",e.cart)||0),0);return a.createElement(a.Fragment,null,a.createElement("div",{className:"msc-promo-code__discount"},a.createElement("div",{className:"msc-promo-code__discount-heading"},this.props.appliedPromoCodeHeadingText),a.createElement(n.k,{data:{price:{CustomerContextualPrice:r}},context:e.context,id:e.id,typeName:e.typeName,className:"msc-promo-code__discount-value"})),e.cart.cart.Coupons.map(r=>{const i=e.removePromoAriaLabelFormat?Object(s.format)(e.removePromoAriaLabelFormat,e.removePromoText,r.Code):"";return a.createElement("div",{key:r.Code,className:"msc-promo-code__line-container"},a.createElement("div",{className:"msc-promo-code__line-value"},r.Code," (",a.createElement(n.k,{data:{price:{CustomerContextualPrice:this._calculateDiscount(r.Code||"",e.cart)}},context:e.context,id:e.id,typeName:e.typeName,className:"msc-promo-code__line-discount-value"}),")"),a.createElement(s.Button,{title:e.removePromoText,className:"msc-promo-code__line__btn-remove",onClick:t,"data-value":r.Code,"aria-label":i},e.removePromoText))}))},this.payLoad=Object(s.getPayloadObject)("click",this.props.telemetryContent,s.TelemetryConstant.ApplyPromoCode),this.state={isCollapseOpen:!1,promoCodeInputValue:"",error:"",canApply:!1}}render(){return a.createElement("div",null,a.createElement("div",{className:"msc-promo-code-heading"},this.props.promoCodeHeadingText),this._renderForm(this.props.promoPlaceholderText,this.props.promoCodeApplyButtonText,this.props.cart),a.createElement("p",{className:this.state.error?"msc-alert-danger":"","aria-live":"assertive"},this.state.error),this._renderAppliedPromoCode(this.props))}}t.default=i},"1Zi0":function(e,t,r){"use strict";r.r(t);r("oLpx"),r("WVYb"),r("LR6M");var a=r("UdvX"),s=r("Hxoz"),n=r("hBpL"),i=r("xT9B"),o=r("TSYQ"),l=r.n(o),c=r("cDcd"),d=r("Wix4"); /*! * Copyright (c) Microsoft Corporation. * All rights reserved. See LICENSE in the project root for license information. */ const u=(e,t)=>e&&e.Dimensions?e.Dimensions.map(r=>1===r.DimensionTypeValue?c.createElement("div",{key:e.RecordId+"ProductDimensions1",className:"msc-cart-line__product-variant-item"},c.createElement("span",{className:"msc-cart-line__product-variant-color"},t.colorString,":",c.createElement("span",{className:"name"},r.DimensionValue&&r.DimensionValue.Value))):2===r.DimensionTypeValue?c.createElement("div",{key:e.RecordId+"ProductDimensions2",className:"msc-cart-line__product-variant-item"},c.createElement("span",{className:"msc-cart-line__product-configuration"},t.configString,":",c.createElement("span",{className:"name"},r.DimensionValue&&r.DimensionValue.Value))):3===r.DimensionTypeValue?c.createElement("div",{key:e.RecordId+"ProductDimensions3",className:"msc-cart-line__product-variant-item"},c.createElement("span",{className:"msc-cart-line__product-variant-size"},t.sizeString,":",c.createElement("span",{className:"name"},r.DimensionValue&&r.DimensionValue.Value))):4===r.DimensionTypeValue?c.createElement("div",{key:e.RecordId+"ProductDimensions4",className:"msc-cart-line__product-variant-item"},c.createElement("span",{className:"msc-cart-line__product-variant-style"},e.IsGiftCard?t.amountString:t.styleString,":",c.createElement("span",{className:"name"},r.DimensionValue&&r.DimensionValue.Value))):null):[],m=e=>e.data.cartLine.DiscountLines&&0!==e.data.cartLine.DiscountLines.length?e.data.cartLine.DiscountLines.map((t,r)=>c.createElement("div",{key:t.OfferId||r,className:"msc-cart-line-item-product-discount"},c.createElement("span",null,t.OfferName?t.OfferName:"",":",` ${e.resources.discountStringText||"Discount"} `),c.createElement("span",{className:"cart-line-item-product-discount-price"},c.createElement(n.k,{data:e.isSalesLine?{price:{CustomerContextualPrice:e.data.cartLine.PeriodicDiscount}}:{price:{CustomerContextualPrice:t.EffectiveAmount,BasePrice:t.EffectiveAmount}},context:e.context,id:e.id,typeName:e.typeName})),c.createElement("span",null,` (${void 0!==t.Percentage?t.Percentage:""}%)`))):null,p=e=>{if(!e.inventoryInformationLabel)return null;const t=e.inventoryLabelClassName?"msc-cart-line__product-inventory-label "+e.inventoryLabelClassName:"msc-cart-line__product-inventory-label";return c.createElement("span",{className:t},e.inventoryInformationLabel)},h=e=>{var t;const r=null===(t=e.context.request.channel)||void 0===t?void 0:t.PickupDeliveryModeCode,a=e.channelDeliveryOptionConfig,s=e.data.cartLine;let i=!1;var o;void 0!==a?i=!(!s.DeliveryMode||null==a||null===(o=a.PickupDeliveryModeCodes)||void 0===o||!o.some(e=>e!==s.DeliveryMode)):i=!(!s.DeliveryMode||s.DeliveryMode===r);if(!i)return;const l=(s.ChargeLines||[]).filter(e=>e.IsShipping);if(0===l.length)return;const d=l.reduce((e,t)=>e+(t.CalculatedAmount||0),0),u=c.createElement(n.k,{data:{price:{CustomerContextualPrice:d}},freePriceText:"Free",context:e.context,id:e.id,typeName:e.typeName,className:"msc-cart-line__freight-actual"});return c.createElement(c.Fragment,null,c.createElement("label",{className:"msc-cart-line__freight-label"},e.resources.shippingChargesText+":"),c.createElement("span",{className:"shipping-value"},u))},g=e=>{var t;const r=null===(t=e.data.cartLine.ChargeLines)||void 0===t?void 0:t.filter(e=>!e.IsShipping);return r&&r.map((t,r)=>t&&t.CalculatedAmount?c.createElement("div",{className:"msc-cart-line__other-charges",key:r},c.createElement("label",{className:"msc-cart-line__other-charges-label"},t.Description+":"),c.createElement("span",{className:"other-charge-value"},c.createElement(n.k,{data:{price:{CustomerContextualPrice:t.CalculatedAmount}},context:e.context,id:e.id,typeName:e.typeName,className:"msc-cart-line__other-charges-actual"}))):"")||void 0};t.default=e=>{const{isSalesLine:t,productUrl:r,resources:o}=e,{product:y,cartLine:b}=e.data,f={sizeString:o.sizeString,colorString:o.colorString,styleString:o.styleString,configString:o.configString,amountString:o.amountString},T=y&&Object(a.getFallbackImageUrl)(y.ItemId,e.context.actionContext.requestContext.apiSettings),_=y&&u(y,f),C=e.imageSettings;C&&(C.cropFocalRegion=!0);const v=m(e),x=p(e),S=h(e),O=g(e),P=Object(s.getPayloadObject)("click",e.telemetryContent,"",null==y?void 0:y.RecordId.toString()),N=Object(s.getTelemetryAttributes)(e.telemetryContent,P),E=(null==y?void 0:y.Name)||b.Description,L=t=>!e.quantityOnChange||e.quantityOnChange(e.data.cartLine,t),I=()=>e.errorMessage?c.createElement("div",{className:"msc-alert__header"},c.createElement("span",{className:"msi-exclamation-triangle"}),c.createElement("span",null,e.errorMessage)):null;return c.createElement("div",{className:"msc-cart-line"},c.createElement("div",{className:"msc-cart-line__product-image"},c.createElement(i.Image,{src:e.primaryImageUrl||"",fallBackSrc:T,altText:E,gridSettings:e.gridSettings,imageSettings:C,loadFailureBehavior:"empty"})),c.createElement("div",{className:"msc-cart-line__content"},c.createElement("div",{className:"msc-cart-line__product"},c.createElement("a",Object.assign({className:"msc-cart-line__product-title",href:r},N),E),a.ArrayExtensions.hasElements(_)?c.createElement("div",{className:"msc-cart-line__product-variants"},_):"",c.createElement("div",{className:"msc-cart-line__product-price"},c.createElement(n.k,{data:t?{price:{CustomerContextualPrice:e.data.cartLine.NetAmount,BasePrice:e.data.cartLine.Price}}:{price:{CustomerContextualPrice:e.data.cartLine.NetAmountWithoutTax,BasePrice:e.data.cartLine.NetPrice}},context:e.context,id:e.id,typeName:e.typeName,className:"discount-value"})),v,x,e.showShippingChargesForLineItems&&c.createElement("div",{className:"msc-cart-line__freight"},S),O),(()=>{const r=[];if(e.isOutOfStock){const e=I();return e?[e]:null}var a;e.isQuantityEditable?r.push(c.createElement("div",{className:"msc-cart-line__product-quantity"},c.createElement("div",{className:"msc-cart-line__product-quantity-label"},o.quantityDisplayString),I(),c.createElement(d.a,{id:"msc-cart-line__quantity_"+(null===(a=e.data.product)||void 0===a?void 0:a.RecordId),max:e.maxQuantity||10,currentCount:e.currentQuantity,onChange:L,inputQuantityAriaLabel:o.inputQuantityAriaLabel,decrementButtonAriaLabel:o.decrementButtonAriaLabel,incrementButtonAriaLabel:o.incrementButtonAriaLabel,key:e.data.cartLine.LineId,disabled:!e.isCartStateReady,isGiftCard:e.data.product.IsGiftCard,telemetryContent:e.telemetryContent}))):r.push(c.createElement("div",{className:l()("msc-cart-line__quantity",{"single-quantity":1===e.data.cartLine.Quantity})},c.createElement("label",{className:"quantity-label"},o.quantityDisplayString,":"),I(),c.createElement("span",{className:"quantity-value"},e.data.cartLine.Quantity)));return r.push(c.createElement("div",{className:"msc-cart-line__product-savings"},c.createElement(n.k,{data:t?{price:{CustomerContextualPrice:e.data.cartLine.NetAmount,BasePrice:e.data.cartLine.Price}}:{price:{CustomerContextualPrice:e.data.cartLine.NetAmountWithoutTax,BasePrice:e.data.cartLine.NetPrice}},context:e.context,id:e.id,typeName:e.typeName,className:"msc-cart-line__product-savings-actual",originalPriceText:o.originalPriceText,currentPriceText:o.currentPriceText}),e.data.cartLine.DiscountAmount&&e.data.cartLine.DiscountAmount>0&&c.createElement(c.Fragment,null,c.createElement("span",{className:"msc-cart-line__product-savings-label"},` ${e.resources.discountStringText||"Discount"} `),c.createElement(n.k,{data:e.isSalesLine?{price:{CustomerContextualPrice:e.data.cartLine.PeriodicDiscount}}:{price:{CustomerContextualPrice:e.data.cartLine.DiscountAmountWithoutTax,BasePrice:e.data.cartLine.DiscountAmount}},context:e.context,id:e.id,typeName:e.typeName,className:"msc-cart-line__product-savings-text"}))||null)),r})()))}},"4arB":function(e,t,r){"use strict";r.d(t,"b",(function(){return c})),r.d(t,"a",(function(){return h}));r("HBRN");var a=r("UdvX"),s=r("Hxoz"),n=r("hBpL"),i=r("xT9B"),o=r("cDcd");const l=e=>{const{onRemoveOrderTemplate:t}=e.handlers,{itemKey:r}=e;t&&r&&t(r)},c=e=>{const{Id:t,orderTemplate:r,removeFromOrderTemplateListText:a,orderTemplateState:c,handlers:m,name:p,imageSettings:h,context:g,telemetryContent:y,enableImageProductLink:b}=e;if(!t)return null;const{onDismiss:f}=m;return{key:t+"-template",orderTemplateImage:d(g,r.orderTemplateLines,h,b),orderTemplateAriaLabel:u(e),orderTemplateName:o.createElement("div",null,o.createElement("div",{className:"ms-order-template__list-item-title"},o.createElement("a",{href:(()=>{const e=Object(i.getUrlSync)("ordertemplate",g.actionContext)||"",r=e.includes("?")?"&":"?";return t?`${e}${r}id=${t}`:""})()},p)),o.createElement("div",{className:"ms-order-template__line-count"},r.totalLines," line items"),o.createElement("hr",{color:"#F9F9F9"})),addToCartButton:o.createElement("div",{className:"ms-order-template__add-to-bag-button-div"},o.createElement(n.a,{id:t,context:g,typeName:e.moduleTypeName,data:{orderTemplate:e.orderTemplate},className:"ms-order-template__add-to-bag-button",addToCartText:e.addToBagText,dialogStrings:e.resources,telemetryContent:y})),removeButton:o.createElement(s.Button,{className:"ms-order-template__remove-list","aria-label":a,onClick:t=>l(e)}),orderTemplateStatusMessage:c&&c.isOpen&&c.userMessage&&o.createElement("div",{className:"ms-orderTemplate__status"},o.createElement(s.Alert,{color:c.statusCssString,isOpen:c.isOpen,toggle:f},o.createElement("span",null,c.userMessage)))}},d=(e,t,r,s)=>{const n={viewports:{xs:{q:"w=140&h=140&m=6",w:0,h:0},lg:{q:"w=140&h=140&m=6",w:0,h:0},xl:{q:"w=140&h=140&m=6",w:0,h:0}},lazyload:!0};if(t){const l=t.length<4?t.length:4;return o.createElement("div",{className:"ms-order-template__image-container"},null==t?void 0:t.slice(0,l).map(t=>{var l,c,d;const u=t.fullProduct?Object(a.getProductUrlSync)(t.fullProduct.ProductDetails,e.actionContext,void 0):"";return o.createElement(i.Image,{key:null===(l=t.fullProduct)||void 0===l?void 0:l.ProductDetails.Name,src:(null===(c=t.fullProduct)||void 0===c?void 0:c.ProductDetails.PrimaryImageUrl)||"",fallBackSrc:Object(a.getFallbackImageUrl)(null===(d=t.fullProduct)||void 0===d?void 0:d.ProductDetails.ItemId,e.actionContext.requestContext.apiSettings)||"",gridSettings:e.request.gridSettings,imageSettings:r||n,loadFailureBehavior:"empty",onClick:s&&(e=>window.location.assign(u)),className:s?"product-link":""})}))}return o.createElement("div",{className:"ms-order-template__image-container"})},u=e=>{const{name:t}=e;return""+t};var m=r("TSYQ"),p=r.n(m);const h=e=>{let{className:t,errorType:r,text:a}=e;switch(r){case"EMPTY":return o.createElement("p",{className:p()("ms-orderTemplateList__message-empty",t)},a);case"FAILED":return o.createElement("p",{className:p()("ms-orderTemplateList__message-failed",t)},a);case"LOADING":default:return o.createElement("p",{className:"ms-orderTemplateList__message-waiting"},a)}}},"81lP":function(e,t,r){"use strict";r.r(t);r("oLpx"),r("WVYb"),r("LR6M");var a=r("UdvX"),s=r("Hxoz"),n=r("hBpL"),i=r("xT9B"),o=r("TSYQ"),l=r.n(o),c=r("cDcd"),d=r("E/MF");const u=(e,t)=>e&&e.Dimensions?e.Dimensions.map(r=>1===r.DimensionTypeValue?c.createElement("div",{key:e.RecordId+"ProductDimensions1",className:"msc-cart-line__product-variant-item"},c.createElement("span",{className:"msc-cart-line__product-variant-color"},t.colorString,":",c.createElement("span",{className:"name"},r.DimensionValue&&r.DimensionValue.Value))):2===r.DimensionTypeValue?c.createElement("div",{key:e.RecordId+"ProductDimensions2",className:"msc-cart-line__product-variant-item"},c.createElement("span",{className:"msc-cart-line__product-configuration"},t.configString,":",c.createElement("span",{className:"name"},r.DimensionValue&&r.DimensionValue.Value))):3===r.DimensionTypeValue?c.createElement("div",{key:e.RecordId+"ProductDimensions3",className:"msc-cart-line__product-variant-item"},c.createElement("span",{className:"msc-cart-line__product-variant-size"},t.sizeString,":",c.createElement("span",{className:"name"},r.DimensionValue&&r.DimensionValue.Value))):4===r.DimensionTypeValue?c.createElement("div",{key:e.RecordId+"ProductDimensions4",className:"msc-cart-line__product-variant-item"},c.createElement("span",{className:"msc-cart-line__product-variant-style"},e.IsGiftCard?t.amountString:t.styleString,":",c.createElement("span",{className:"name"},r.DimensionValue&&r.DimensionValue.Value))):null):[],m=e=>e.data.cartLine.DiscountLines&&0!==e.data.cartLine.DiscountLines.length?e.data.cartLine.DiscountLines.map((t,r)=>c.createElement("div",{key:t.OfferId||r,className:"msc-cart-line-item-product-discount"},c.createElement("span",null,t.OfferName?t.OfferName:"",":",` ${e.resources.discountStringText||"Discount"} `),c.createElement("span",{className:"cart-line-item-product-discount-price"},c.createElement(n.k,{data:e.isSalesLine?{price:{CustomerContextualPrice:e.data.cartLine.PeriodicDiscount}}:{price:{CustomerContextualPrice:t.EffectiveAmount,BasePrice:t.EffectiveAmount}},context:e.context,id:e.id,typeName:e.typeName})),c.createElement("span",null,` (${void 0!==t.Percentage?t.Percentage:""}%)`))):null,p=e=>{if(!e.inventoryInformationLabel)return null;const t=e.inventoryLabelClassName?"msc-cart-line__product-inventory-label "+e.inventoryLabelClassName:"msc-cart-line__product-inventory-label";return c.createElement("span",{className:t},e.inventoryInformationLabel)},h=e=>{var t;const r=null===(t=e.context.request.channel)||void 0===t?void 0:t.PickupDeliveryModeCode,a=e.channelDeliveryOptionConfig,s=e.data.cartLine;let i=!1;var o;void 0!==a?i=!(!s.DeliveryMode||null==a||null===(o=a.PickupDeliveryModeCodes)||void 0===o||!o.some(e=>e!==s.DeliveryMode)):i=!(!s.DeliveryMode||s.DeliveryMode===r);if(!i)return;const l=(s.ChargeLines||[]).filter(e=>e.IsShipping);if(0===l.length)return;const d=l.reduce((e,t)=>e+(t.CalculatedAmount||0),0),u=c.createElement(n.k,{data:{price:{CustomerContextualPrice:d}},freePriceText:"Free",context:e.context,id:e.id,typeName:e.typeName,className:"msc-cart-line__freight-actual"});return c.createElement(c.Fragment,null,c.createElement("label",{className:"msc-cart-line__freight-label"},e.resources.shippingChargesText+":"),c.createElement("span",{className:"shipping-value"},u))},g=e=>{var t;const r=null===(t=e.data.cartLine.ChargeLines)||void 0===t?void 0:t.filter(e=>!e.IsShipping);return r&&r.map((t,r)=>t&&t.CalculatedAmount?c.createElement("div",{className:"msc-cart-line__other-charges",key:r},c.createElement("label",{className:"msc-cart-line__other-charges-label"},t.Description+":"),c.createElement("span",{className:"other-charge-value"},c.createElement(n.k,{data:{price:{CustomerContextualPrice:t.CalculatedAmount}},context:e.context,id:e.id,typeName:e.typeName,className:"msc-cart-line__other-charges-actual"}))):"")||void 0};t.default=e=>{var t,r;const{isSalesLine:o,productUrl:y,resources:b}=e,{product:f,cartLine:T}=e.data,_={sizeString:b.sizeString,colorString:b.colorString,styleString:b.styleString,configString:b.configString,amountString:b.amountString},C=f&&Object(a.getFallbackImageUrl)(f.ItemId,e.context.actionContext.requestContext.apiSettings),v=f&&u(f,_),x=e.imageSettings;x&&(x.cropFocalRegion=!0);const S=m(e),O=p(e),P=h(e),N=g(e),E=Object(s.getPayloadObject)("click",e.telemetryContent,"",null==f?void 0:f.RecordId.toString()),L=Object(s.getTelemetryAttributes)(e.telemetryContent,E),I=(null==f?void 0:f.Name)||T.Description,D=t=>!e.quantityOnChange||e.quantityOnChange(e.data.cartLine,t),w=()=>e.errorMessage?c.createElement("div",{className:"msc-alert__header"},c.createElement("span",{className:"msi-exclamation-triangle"}),c.createElement("span",null,e.errorMessage)):null,k=null==e||null===(t=e.data)||void 0===t||null===(r=t.cartLine)||void 0===r?void 0:r.ReasonCodeLines,A=[];return k&&k.length>0&&k.map(t=>{const r=t.Information?t.Information:"",a=r.substr(0,r.indexOf("qty:")),s=r.indexOf("qty:")+5,n=r.indexOf("price"),i=r.substr(s,n-s),o=r.substr(n+7,r.length);A.push({name:a,qty:i,price:null==e?void 0:e.context.cultureFormatter.formatCurrency(o)})}),c.createElement("div",{className:"msc-cart-line product-type__"+(A&&A.length>0?"pick-mix":"default")},c.createElement("div",{className:"msc-cart-line__product-image"},c.createElement(i.Image,{src:e.primaryImageUrl||"",fallBackSrc:C,altText:I,gridSettings:e.gridSettings,imageSettings:x,loadFailureBehavior:"empty"})),c.createElement("div",{className:"msc-cart-line__content"},c.createElement("div",{className:"msc-cart-line__product"},c.createElement("div",{className:"msc-cart-line__product-title"},c.createElement("a",Object.assign({href:y},L),I),a.ArrayExtensions.hasElements(v)?c.createElement("div",{className:"msc-cart-line__product-variants"},v):"",A&&A.length>0?c.createElement("ul",null,A.map(e=>""!==(null==e?void 0:e.name)&&c.createElement("li",{className:"subproduct--pm"},null==e?void 0:e.qty," x ",null==e?void 0:e.name," ",c.createElement("span",{className:"subproduct--pm_price"},null==e?void 0:e.price)))):""),v&&v.length>0?c.createElement("div",{className:"msc-cart-line__product-variants"},v):"",c.createElement("div",{className:"msc-cart-line__product-price"},c.createElement(n.k,{data:o?{price:{CustomerContextualPrice:e.data.cartLine.NetAmount,BasePrice:e.data.cartLine.Price}}:{price:{CustomerContextualPrice:e.data.cartLine.NetAmountWithoutTax,BasePrice:e.data.cartLine.NetPrice}},context:e.context,id:e.id,typeName:e.typeName,className:"discount-value"})),S,O,e.showShippingChargesForLineItems&&c.createElement("div",{className:"msc-cart-line__freight"},P),N),(()=>{const t=[];if(e.isOutOfStock){const e=w();return e?[e]:null}var r;e.isQuantityEditable?t.push(c.createElement("div",{className:"msc-cart-line__product-quantity"},c.createElement("div",{className:"msc-cart-line__product-quantity-label"},b.quantityDisplayString),w(),c.createElement(d.Quantity,{id:"msc-cart-line__quantity_"+(null===(r=e.data.product)||void 0===r?void 0:r.RecordId),max:e.maxQuantity||10,currentCount:e.currentQuantity,onChange:D,inputQuantityAriaLabel:b.inputQuantityAriaLabel,decrementButtonAriaLabel:b.decrementButtonAriaLabel,incrementButtonAriaLabel:b.incrementButtonAriaLabel,key:e.data.cartLine.LineId,disabled:!e.isCartStateReady,isGiftCard:e.data.product.IsGiftCard,telemetryContent:e.telemetryContent}))):t.push(c.createElement("div",{className:l()("msc-cart-line__quantity",{"single-quantity":1===e.data.cartLine.Quantity})},c.createElement("label",{className:"quantity-label"},b.quantityDisplayString,":"),w(),c.createElement("span",{className:"quantity-value"},e.data.cartLine.Quantity)));return t.push(c.createElement("div",{className:"msc-cart-line__product-savings"},c.createElement(n.k,{data:o?{price:{CustomerContextualPrice:e.data.cartLine.NetAmount,BasePrice:e.data.cartLine.Price}}:{price:{CustomerContextualPrice:e.data.cartLine.NetAmountWithoutTax,BasePrice:e.data.cartLine.NetPrice}},context:e.context,id:e.id,typeName:e.typeName,className:"msc-cart-line__product-savings-actual",originalPriceText:b.originalPriceText,currentPriceText:b.currentPriceText}),e.data.cartLine.DiscountAmount&&e.data.cartLine.DiscountAmount>0&&c.createElement(c.Fragment,null,c.createElement("span",{className:"msc-cart-line__product-savings-label"},` ${e.resources.discountStringText||"Discount"} `),c.createElement(n.k,{data:e.isSalesLine?{price:{CustomerContextualPrice:e.data.cartLine.PeriodicDiscount}}:{price:{CustomerContextualPrice:e.data.cartLine.DiscountAmountWithoutTax,BasePrice:e.data.cartLine.DiscountAmount}},context:e.context,id:e.id,typeName:e.typeName,className:"msc-cart-line__product-savings-text"}))||null)),t})()))}},AdTS:function(e,t){},C2wQ:function(e,t,r){"use strict";r.r(t);r("9VTn");var a=r("rePB"),s=(r("LR6M"),r("mrSG")),n=r("Hxoz"),i=r("hBpL"),o=r("xT9B"),l=r("TSYQ"),c=r.n(l),d=r("2vnA"),u=r("okNM"),m=r("cDcd");class p extends m.PureComponent{constructor(e){super(e);const t=Object(n.getPayloadObject)("click",e.telemetryContent,n.TelemetryConstant.Logo);this.attributes=Object(n.getTelemetryAttributes)(e.telemetryContent,t)}render(){return m.createElement("div",{className:this.props.className},this._renderLogo(this.props))}_renderLogo(e){return e.link&&e.link.linkUrl.destinationUrl?m.createElement("a",Object.assign({href:e.link.linkUrl.destinationUrl,"aria-label":e.link.ariaLabel,target:e.link.openInNewTab?"_blank":void 0},this.attributes),this._renderImage(e)):this._renderImage(e)}_renderImage(e){const t={viewports:{xs:{q:"w=132&h=28&m=6",w:0,h:0},lg:{q:"w=160&h=48&m=6",w:0,h:0}},lazyload:!0};return m.createElement(o.Image,Object.assign({},e.image,{gridSettings:this.props.gridSettings,imageSettings:e&&e.image&&e.image.imageSettings||t,loadFailureBehavior:"default",editProps:{key:e.image||{},requestContext:this.props.requestContext}}))}}let h=class extends m.Component{constructor(e){super(e);const t=Object(n.getPayloadObject)("click",e.telemetryContent,n.TelemetryConstant.NavIcon);this.attributes=Object(n.getTelemetryAttributes)(e.telemetryContent,t)}render(){return m.createElement(n.Button,Object.assign({className:"ms-header__nav-icon",onClick:this.props.toggleNavBar,title:this.props.resources.mobileHamburgerAriaLabel,"aria-label":this.props.resources.mobileHamburgerAriaLabel,"aria-expanded":this.props.isExpanded,"aria-controls":this.props.targetId},this.attributes))}};h=Object(s.__decorate)([u.a],h);r("y/s1"),r("ES/9");let g=class extends m.PureComponent{constructor(){super(...arguments),this.handleClick=()=>this._findPreferreStoreOnClick(this.props)}render(){const{data:{storeSelectorStateManager:{result:e}},slots:t,resources:r}=this.props;if(t&&t.storeSelector&&t.storeSelector.length){const a=e.preferredStore&&e.preferredStore.StoreName?e.preferredStore.StoreName:r.headerPreferredStoreText;return m.createElement("div",{className:"ms-header__preferred-store-container"},m.createElement("button",{className:"ms-header__preferred-store-btn msc-btn",color:"secondary","aria-label":r.headerPreferredStoreAriaLabel,onClick:this.handleClick},m.createElement("span",{className:"ms-header__preferred-store-text"},a)),t.storeSelector)}}async _findPreferreStoreOnClick(e){const{data:{storeSelectorStateManager:{result:t}},modules:r}=e;if(!t)return;let a="";r&&Object.keys(r).length>0&&r.storeSelector&&r.storeSelector.length>0&&(a=r.storeSelector[0].id),t.openDialog({id:a,showMapViewLink:!1,onLocationSelected:e=>Promise.resolve()}).catch(t=>{e.telemetry&&(e.telemetry.error(t.message),e.telemetry.debug("Unable to set preferred store"))})}};g=Object(s.__decorate)([u.a],g);function y(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,a)}return r}function b(e){for(var t=1;tt=>{this.props.config.myAccountLinks&&this.props.config.myAccountLinks[e]&&(this.props.config.myAccountLinks[e].linkText=t.target.value)},this.popOverRef=m.createRef(),this._toggleNavbar=this._toggleNavbar.bind(this),this._togglePopover=this._togglePopover.bind(this),this._keydown=this._keydown.bind(this),this.state={mobileMenuCollapsed:!0,signinPopoverOpen:!1},this.telemetryContent=Object(n.getTelemetryObject)(this.props.context.request.telemetryPageName,this.props.friendlyName,this.props.telemetry)}get displayName(){var e;const t=null===(e=this.props.data.accountInformation)||void 0===e?void 0:e.result;return t?t.FirstName||t.Name:void 0}componentDidMount(){o.msdyn365Commerce.isBrowser&&window.addEventListener("keydown",this._keydown),Object(d.o)(()=>this.props.data.cart.result,()=>{this.cart=this.props.data.cart.result})}componentWillUnmount(){o.msdyn365Commerce.isBrowser&&window.removeEventListener("keydown",this._keydown,!1)}render(){const{id:e,typeName:t,data:{accountInformation:r,storeSelectorStateManager:{result:a}},context:{request:{user:s}},context:o,resources:{cartLabel:l,cartQtyLabel:d}}=this.props,{logoLink:u,logoImage:y}=this.props.config,f=c()("ms-header",this.props.config.className),T=r&&r.result,_=this._getSlot("cartIcon"),C=this._getSlot("menuBar"),v=this._getSlot("search"),x=this._getSlot("siteOptions"),S=this._getSlot("storeSelector"),O=b(b(b({},this.props),this.state),{},{logo:m.createElement(p,Object.assign({},{link:u,image:y,className:"ms-header__logo",gridSettings:this.props.context.request.gridSettings,requestContext:this.props.context.request,telemetryContent:this.telemetryContent})),wishListIconDesktop:m.createElement(i.s,{className:"ms-header__wishlist-desktop",showButtonTooltip:!0,wishlistTooltipText:this.props.resources.wishlistTooltipText,context:o,id:e,typeName:t,telemetryContent:this.telemetryContent,data:{}}),wishListIconMobile:m.createElement(i.s,{className:"ms-header__wishlist-mobile",showButtonTooltip:!0,wishlistTooltipText:this.props.resources.wishlistTooltipText,context:o,id:e,typeName:t,telemetryContent:this.telemetryContent,data:{}}),cartIcon:_&&_.length>0?_[0]:m.createElement(i.f,{cartLabel:l,cartQtyLabel:d,context:o,id:e,typeName:t,telemetryContent:this.telemetryContent,data:{cart:this.cart}}),navIcon:m.createElement(h,Object.assign({},{resources:this.props.resources,isExpanded:!this.state.mobileMenuCollapsed,targetId:"header-nav-mobile",toggleNavBar:this._toggleNavbar,telemetryContent:this.telemetryContent})),menuBar:C&&C.length&&C||[],search:v&&v.length&&v||[],siteOptions:x&&x.length&&x||[],className:f,HeaderTag:{moduleProps:this.props,className:c()(f),tag:"header"},HeaderContainer:{className:c()("ms-header__container")},HeaderTopBarContainer:{className:c()("ms-header__topbar")},Divider:{className:c()("ms-header__divider")},MobileMenuContainer:{tag:n.Modal,id:"header-nav-mobile",className:"ms-header__mobile-hamburger",isOpen:!this.state.mobileMenuCollapsed,wrapClassName:"ms-header__modal",toggle:this._toggleNavbar},MobileMenuHeader:m.createElement(n.ModalHeader,{className:"ms-header__mobile-hamburger-menu-header",toggle:this._toggleNavbar}),MobileMenuBodyContainer:{tag:n.ModalBody,className:"ms-header__mobile-hamburger-menu-body"},MobileMenuLinksContainer:{className:"ms-header__mobile-hamburger-menu-links"},AccountInfoDropdownParentContainer:{className:"ms-header__account-info"},AccountInfoDropdownPopoverConentContainer:T&&this.displayName&&{tag:n.Popover,id:"myprofilePopover",className:"ms-header__account-info-content",placement:"bottom",isOpen:this.state.signinPopoverOpen,target:this.popOverRef,toggle:this._togglePopover}||void 0,signInLink:this._getSigninButton(T,s,this.props.resources),signOutLink:this._getSignOutButton(T,s,this.props.resources),accountInfoDropdownButton:this._getAccountInfoDropdownButton(T),accountLinks:this._getAccountLinks(T),preferredStore:S&&S.length&&a&&m.createElement(g,Object.assign({},this.props))});return this.props.renderView(O)}_getSlot(e){const{slots:t}=this.props;return t&&t[e]&&t[e].length&&t[e]||null}_getSigninButton(e,t,r){const a=Object(n.getPayloadObject)("click",this.telemetryContent,n.TelemetryConstant.SignIn),s=Object(n.getTelemetryAttributes)(this.telemetryContent,a);return!e&&m.createElement(n.Button,Object.assign({className:"ms-header__signin-button",title:r.signInLinkText,href:t&&t.signInUrl,"aria-label":r.signInLinkAriaText,onClick:Object(n.onTelemetryClick)(this.telemetryContent,a,"Sign in")},s),m.createElement("span",{className:"ms-header__signin-button-text","aria-hidden":!0},r.signInLinkText))}_getSignOutButton(e,t,r){const a=Object(n.getPayloadObject)("click",this.telemetryContent,n.TelemetryConstant.SignOut),s=Object(n.getTelemetryAttributes)(this.telemetryContent,a);return e&&this.displayName&&m.createElement(n.Button,Object.assign({className:"ms-header__signout-button",title:r.signOutLinkText,href:t&&t.signOutUrl||"","aria-label":r.signOutLinkAriaText,onClick:Object(n.onTelemetryClick)(this.telemetryContent,a,"Sign out")},s),m.createElement("span",{className:"ms-header__signout-button-text","aria-hidden":!0},r.signOutLinkText))}_getAccountInfoDropdownButton(e){const t=Object(n.getPayloadObject)("click",this.telemetryContent,n.TelemetryConstant.MyProfile),r=Object(n.getTelemetryAttributes)(this.telemetryContent,t);return e&&this.displayName&&m.createElement(n.Button,Object.assign({innerRef:this.popOverRef,className:"ms-header__profile-button","aria-describedby":"myprofilePopover",onClick:this._togglePopover,color:"link","aria-expanded":this.state.signinPopoverOpen},r),m.createElement("span",{className:"ms-profile-button-text"},this.displayName))}_getAccountLinks(e){const{myAccountLinks:t}=this.props.config,r=Object(n.getPayloadObject)("click",this.telemetryContent,"");if(e&&this.displayName&&t&&t.length)return t.map((e,t)=>{r.contentAction.etext=e.linkText;const a=Object(n.getTelemetryAttributes)(this.telemetryContent,r),s={ariaLabel:e.ariaLabel,className:"ms-signin-info__account-link-button",linkText:e.linkText,linkUrl:e.linkUrl.destinationUrl,openInNewTab:e.openInNewTab,role:"button",additionalProperties:a};return m.createElement(o.Link,{key:t,link:s,editProps:{onTextChange:this.handleLinkTextChange(t),requestContext:this.props.context.request}})})}_toggleNavbar(){this.setState({mobileMenuCollapsed:!this.state.mobileMenuCollapsed})}_togglePopover(){this.setState({signinPopoverOpen:!this.state.signinPopoverOpen})}_keydown(e){27===e.keyCode&&this.setState({mobileMenuCollapsed:!0})}};Object(s.__decorate)([d.e],f.prototype,"displayName",null),f=Object(s.__decorate)([u.a],f);t.default=f},CG8G:function(e,t,r){"use strict";r.r(t);r("9VTn");var a=r("Ff2n"),s=r("rePB"),n=(r("HBRN"),r("ES/9"),r("y/s1"),r("Yw3D"),r("BDvt"),r("WVYb"),r("LR6M"),r("mrSG")),i=r("UdvX"),o=r("Hxoz"),l=r("hBpL"),c=r("xT9B"),d=r("u8oO"),u=r("57kZ"),m=r("sF6Z"),p=r("TSYQ"),h=r.n(p),g=r("sEfC"),y=r.n(g),b=r("2vnA"),f=r("okNM"),T=r("cDcd"),_=r("o1TC"),C=r("Chzd");function v(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,a)}return r}function x(e){for(var t=1;t{const{context:e,resources:t}=this.props,{telemetry:r}=e,{removeSelectedFailureMessage:a,removeSelectedSuccessMessage:s}=t,n=this.state.productSelection,i=n&&n.length&&n.filter(e=>e.isChecked).map(e=>e.productListLine);if(i&&i.length){const t=i[0].ProductListId;Object(m.e)({callerContext:e.actionContext},t,i).then(()=>{this.setState({userMessage:s,statusCssString:"success",messageGlyph:"fas fa-check",isOpen:!0}),window.location.reload()}).catch(e=>{r.warning("[order-template-lines] Unable remove items from the order template lines"),r.error(e),this.setState({userMessage:a,statusCssString:"success",messageGlyph:"fas fa-check",isOpen:!0})})}},this._getOrderTemplatePageUrl=()=>{var e;let t=Object(c.getUrlSync)("ordertemplate",this.props.context.actionContext)||"";return t=t.includes("?")?t.substr(0,t.indexOf("?")):t,null!==(e=this.props.data.orderTemplate.result)&&void 0!==e&&e.productList.Id?`${t}?id=${this.props.data.orderTemplate.result.productList.Id}`:""},this._onAddSelectionToBag=async()=>{const{context:e,resources:t}=this.props,{addedToCartFailureMessage:r,addedToCartSuccessMessage:a}=t,s=this.state.productSelection,n=await Object(d.a)(e.actionContext),i=s.filter(e=>e.isChecked);if(i.length){const t=i.map(e=>{var t,r;return{ItemId:null===(t=e.fullProduct)||void 0===t?void 0:t.ProductDetails.ItemId,ProductId:e.productListLine.ProductId,Quantity:e.productListLine.Quantity||1,TrackingId:"",UnitOfMeasureSymbol:e.productListLine.UnitOfMeasure||(null===(r=e.fullProduct)||void 0===r?void 0:r.ProductDetails.DefaultUnitOfMeasure)}})||[];return Object(u.a)({callerContext:e.actionContext},n.cart.Id,t,n.cart.Version).then(async r=>{e.telemetry.trace(`Order template; selected line items (${t.map(e=>e.ItemId).join(",")}) added to cart: ${n.cart.Id}`),await n.refreshCart({}),this.setState({userMessage:a,statusCssString:"success",messageGlyph:"fas fa-check",isOpen:!0})}).catch(t=>{e.telemetry.trace("Unable to add order template to cart."),this.setState({userMessage:r,statusCssString:"danger",messageGlyph:"fas fa-exclamation-triangle",isOpen:!0})})}return Promise.resolve(void 0)},this._getCurrentUrl=e=>c.default.isBrowser?new URL(window.location.href):new URL(e.url.requestUrl.href),this._renderItemAddedToCartDialog=()=>{if(!this.state.itemAddedToCartDialogData)return null;return T.createElement(l.h,{className:"msc-item-added-to-cart-dialog",id:this.props.id,typeName:this.props.typeName,context:this.props.context,dialogStrings:this._generateItemAddedToCartDialogResources(),data:this.state.itemAddedToCartDialogData,modalOpen:this.state.isItemAddedToOrderTemplateOpen,onClose:()=>{this.setState({itemKey:this.state.itemKey,userMessage:this.state.userMessage,statusCssString:this.state.statusCssString,messageGlyph:this.state.messageGlyph,isOpen:this.state.isOpen,isItemAddedToOrderTemplateOpen:!1})}})},this._renderPagination=()=>{const{config:e,context:t,data:r,resources:a}=this.props,s=r&&r.orderTemplate&&r.orderTemplate.result;if(!s)return null;const n=this._getCurrentUrl(t.request),i=e.itemsPerPage||50,l=this._getCurrentPageNumber()*i,c=s&&s.totalLines,d=a.flipperPrevious,u=a.flipperNext;return c<=i?null:T.createElement(o.UncontrolledPagination,{className:this.className+"__pagination",role:"navigation","aria-label":a.paginationAriaLabel,url:n.href,qsp:"skip",items:c,itemsPerPage:i,startingItem:l,previousText:T.createElement("div",{className:"msc-pagination__prev"},T.createElement("span",{className:this.props.config.className+"__pagination-left","aria-hidden":"true"}),T.createElement("span",{className:"prev-text"},d)),nextText:T.createElement("div",{className:"msc-pagination__next"},T.createElement("span",{className:"next-text"},u),T.createElement("span",{className:this.props.config.className+"__pagination-right","aria-hidden":"true"})),previousAriaLabel:d,nextAriaLabel:u})},this._toggleDetailsDisplayed=e=>{let t={isDetailsDisplayed:!this.state.isDetailsDisplayed};e&&(t=x(x({},t),{detailedProductView:Object(_.OrderTemplateMobileLineView)(e)})),this.setState(t)},this._onDismiss=()=>{this.setState({isOpen:!1})},this._changeQuantity=(e,t,r)=>{const{context:s,data:n,telemetry:i,config:o}=this.props,{orderTemplate:l}=n;if(s&&l.result){const n=l&&l.result&&l.result.orderTemplateLines;if(n){const c=n.findIndex(t=>t.productListLine.LineId===e),d=x({},n[c]);if(n[c].productListLine.Quantity===t)return;const u=d.productListLine.Quantity;d.productListLine.Quantity=t;const{fullProduct:p}=d,h=Object(a.a)(d,["fullProduct"]);r&&(r.quantity=t,this.setState({detailedProductView:Object(_.OrderTemplateMobileLineView)(r)})),Object(m.h)({callerContext:s.actionContext},l.result.productList.Id,[h.productListLine]).then(t=>{if(this.setState({itemKey:e,userMessage:"",statusCssString:"success",messageGlyph:"fas fa-check",isOpen:!1}),t){const r=t.find(t=>t.LineId===e);n[c].productListLine=r;const a=[...n];a[c]={fullProduct:p,productListLine:r};const i=x(x({},l.result),{},{ProductListLines:a});s.actionContext.update(new C.ActiveOrderTemplateLinesInput(s.actionContext.requestContext,o),i)}}).catch(t=>{i.warning("[order-template-lines] Unable to update product quantity."),i.error(t);r?(r&&(r.productListLine.Quantity=u),this.setState({itemKey:e,userMessage:"Failed to update quantity value.",statusCssString:"danger",messageGlyph:"fas fa-exclamation-triangle",isOpen:!0,detailedProductView:Object(_.OrderTemplateMobileLineView)(r)})):(d.productListLine.Quantity=u,this.setState({itemKey:e,userMessage:"Failed to update quantity value.",statusCssString:"danger",messageGlyph:"fas fa-exclamation-triangle",isOpen:!0}))})}}},this._addItemToBag=(e,t,r)=>{const{context:a,data:s,resources:n,telemetry:o}=this.props,{cart:l}=s,{maxQuantityLimitText:d,addedToCartFailureMessage:u}=n;if(a&&l.result){const s={product:e,count:t};l.result.addProductToCart(s).then(s=>"SUCCESS"===s.status?Object(i.getPriceForSelectedVariant)(new i.PriceForSelectedVariantInput(e.RecordId,this.props.context.actionContext.requestContext.apiSettings.channelId,e),this.props.context.actionContext).then(a=>a?(this.setState({itemKey:r,userMessage:"",statusCssString:"success",messageGlyph:"fas fa-check",isOpen:!1,isItemAddedToOrderTemplateOpen:!0,itemAddedToCartDialogData:{product:e,productPrice:a,quantity:t},isDetailsDisplayed:!1}),c.AsyncResult.resolve()):c.AsyncResult.reject("Failed to retrieve product price")):"MAXQUANTITY"===s.substatus?(this.setState({itemKey:r,userMessage:d.replace("{curQuantity}",t.toString()).replace("{maxQuantity}",a.app.config.maxQuantityForProductListLineItem.toString())||`You can only add ${a.app.config.maxQuantityForProductListLineItem} of this item to your shopping bag`,statusCssString:"danger",messageGlyph:"fas fa-exclamation-triangle",isOpen:!0}),c.AsyncResult.resolve()):(o.debug("[order-template-lines] Unable to Update Cart Line from the order template lines"),this.setState({itemKey:r,userMessage:u,statusCssString:"danger",messageGlyph:"fas fa-exclamation-triangle",isOpen:!0}),c.AsyncResult.resolve())).catch(e=>{o.warning(e),o.debug("[order-template-lines] Error trying to Update Cart Line from the order template lines"),this.setState({itemKey:r,userMessage:u,statusCssString:"danger",messageGlyph:"fas fa-exclamation-triangle",isOpen:!0})})}},this._removeItemFromOrderTemplateLines=e=>{const{context:t,data:r,telemetry:a}=this.props,{orderTemplate:s}=r;if(t&&t.actionContext){t.request.user.isAuthenticated&&t.request.user.token&&s.result&&s.result&&e?Object(m.e)({callerContext:t.actionContext},e.productListLine.ProductListId,[e.productListLine]).then(()=>{window.location.reload(!1)}).catch(e=>{a.warning("[order-template-lines] Unable remove items from the order template lines"),a.error(e)}):a.warning("[order-template-lines] Unable remove items from the order template lines user token or lineItemID was not found")}},this._renameTemplate=async e=>(window.location.reload(!1),Promise.resolve()),this._removeTemplate=()=>{const{context:e,data:t,telemetry:r,resources:a}=this.props,{orderTemplate:s}=t;if(e&&e.actionContext){if(e.request.user.isAuthenticated&&e.request.user.token&&s&&s.result){Object(m.c)({callerContext:e.actionContext},s.result.productList).then().catch(e=>{var t;r.warning("[order-template] Unable to delete order template."),r.error(e),this.setState({itemKey:(null===(t=s.result)||void 0===t?void 0:t.productList.Id)||"",userMessage:a.deleteOrderTemplateFailedText,statusCssString:"danger",messageGlyph:"fas fa-exclamation-triangle",isOpen:!0})});const t=Object(c.getUrlSync)("ordertemplatelist",this.props.context.actionContext);t&&window.location.assign(t)}else r.warning("[order-template] Failed to delete order template. Order template was not found")}else r.warning("[order-template] Failed to delete order template.")},this._getViewport=()=>{const{context:e}=this.props;if(e.request&&e.request.device&&"Mobile"===e.request.device.Type)return"xs";if(void 0!==typeof window&&window.innerWidth){const t=e.request.gridSettings;if(t)return t.xs&&window.innerWidth<=t.xs.w?"xs":t.sm&&window.innerWidth<=t.sm.w?"sm":t.md&&window.innerWidth<=t.md.w?"md":t.lg&&window.innerWidth<=t.lg.w?"lg":"xl"}return"xs"},this.className="ms-order-template",this._viewport=e.context.request&&e.context.request.device&&"Mobile"===e.context.request.device.Type?"xs":"lg",this._updateViewport=this._updateViewport.bind(this),this.state={itemKey:"",userMessage:"",statusCssString:"success",messageGlyph:"fas fa-check",isOpen:!1,isItemAddedToOrderTemplateOpen:!1,isConfirmAddSelectionToBagModalOpen:!1,productSelection:[],isDetailsDisplayed:!1},this.telemetryContent=Object(o.getTelemetryObject)(this.props.context.request.telemetryPageName,this.props.friendlyName,this.props.telemetry),this._updateViewport(),this.props.context.request.user.isAuthenticated||window.location.assign(this.props.context.request.user.signInUrl||"/")}get isMobile(){return"xs"===this._viewport||"sm"===this._viewport}async componentDidMount(){this.setState({});const e=await this.props.data.orderTemplate;this.props.config.heading.text=e.productList.Name||"",this.setState({productSelection:e.orderTemplateLines}),void 0!==typeof window&&window.addEventListener&&(window.addEventListener("resize",this._updateViewport),this._updateViewport())}componentWillUnmount(){void 0!==typeof window&&window.addEventListener&&window.removeEventListener("resize",this._updateViewport)}render(){const{heading:e,className:t}=this.props.config,{emptyOrderTemplateLinesText:r,errorGettingOrderTemplateLines:a}=this.props.resources,{orderTemplate:s,cart:n}=this.props.data;if("LOADING"===n.status||"LOADING"===s.status){const r=x(x({},this.props),{},{OrderTemplateLines:{moduleProps:this.props,className:h()(this.className,t)},status:"LOADING",statusMessage:T.createElement(_.OrderTemplateLinesStatusMessage,{errorType:"LOADING",text:"Loading..."}),heading:e&&T.createElement(o.Heading,Object.assign({className:this.className+"__heading"},e)),resources:this.props.resources});return this.props.renderView(r)}if("FAILED"===n.status||"FAILED"===s.status){const r=x(x({},this.props),{},{OrderTemplateLines:{moduleProps:this.props,className:h()(""+this.className,t)},status:"FAILED",statusMessage:T.createElement(_.OrderTemplateLinesStatusMessage,{errorType:"FAILED",text:a}),heading:e&&T.createElement(o.Heading,Object.assign({className:this.className+"__heading"},e)),resources:this.props.resources});return this.props.renderView(r)}const i=s&&s.result,l=i&&i.orderTemplateLines;if(!i||!l||0===l.length){if(i&&!this._isFirstPage())return window.location.href=this._getOrderTemplatePageUrl(),null;const a=x(x({},this.props),{},{OrderTemplateLines:{moduleProps:this.props,className:h()(""+this.className,t)},status:"EMPTY",statusMessage:T.createElement(_.OrderTemplateLinesStatusMessage,{errorType:"EMPTY",text:r}),heading:e&&T.createElement(o.Heading,Object.assign({className:this.className+"__heading"},e)),resources:this.props.resources});return this.props.renderView(a)}const c=x(x({},this.props),{},{OrderTemplateLines:{moduleProps:this.props,className:h()(""+this.className,t)},status:"SUCCESS",productsStatusMessage:this.state.isOpen&&T.createElement("div",{className:this.className+"-products-status"},T.createElement(o.Alert,{color:this.state.statusCssString,isOpen:this.state.isOpen,toggle:this._onDismiss},T.createElement("span",null,this.state.userMessage))),heading:e&&T.createElement(o.Heading,Object.assign({className:this.className+"__heading"},e)),OrderTemplateActions:{className:this.className+"-action-bar",tag:"div"},ProductsTable:{className:this.className+"__table",tag:"table"},ProductsTableRow:{className:this.className+"-table-line",tag:"tr"},ProductsTableHeading:this._renderProductListHeader(this.props.resources),ProductDetails:{className:this.className+"-table-line__link",tag:"a"},orderLines:this._renderProductList(),callbacks:{updateQuantity:y()(this._changeQuantity,2e3)},orderActions:this._renderOrderTemplateActions(i),pagination:this._renderPagination(),itemAddedToCartDialog:this._renderItemAddedToCartDialog(),bulkOrderLineActions:this._getOrderTemplateLineActions(i.productList.Id),isDetailsDisplayed:this.state.isDetailsDisplayed,toggleDetailsDisplayed:this._toggleDetailsDisplayed,detailedProductView:this.state.detailedProductView,isMobile:this.isMobile});return this.props.renderView(c)}onSelect(e,t){e.isChecked=t;const r=this.state.productSelection.map(r=>{var a,s;return(null===(a=r.fullProduct)||void 0===a?void 0:a.ProductDetails.ItemId)===(null===(s=e.fullProduct)||void 0===s?void 0:s.ProductDetails.ItemId)&&(e.isChecked=t),r})||[];this.setState({productSelection:r})}onSelectAll(e){const t=this.state.productSelection.map(t=>(t.isChecked=e,t))||[];this.setState({productSelection:t})}_renderProductListHeader(e){const{productNumberText:t,productText:r,productUnitPriceText:a,productUOMText:s,productQuantityText:n,productActionsText:i}=e,o={productNumber:t,productName:r,productUnitPrice:a,productUOM:s,productQuantity:n,productActions:i,lines:this.state.productSelection,isMobile:this.isMobile,clickHandler:e=>this.onSelectAll(e)};return T.createElement(_.OrderTemplateTableHeading,Object.assign({},o))}_getOrderTemplateLineActions(e){return T.createElement(_.OrderTemplateBulkActions,Object.assign({},this.props,{orderTemplateId:e,selectedLines:this.state.productSelection.filter(e=>e.isChecked),onAddSelectionToBag:this._onAddSelectionToBag,onRemoveSelection:this._onRemoveSelection,isMinifiedView:this.isMobile}))}_generateLinesAddedToCartDialogResources(){return{viewCartButtonText:this.props.resources.viewCartButtonText,orderTemplateCloseButtonText:this.props.resources.orderTemplateCloseButtonText,linesAddedToCartHeaderItemsOneText:this.props.resources.linesAddedToCartHeaderItemsOneText,linesAddedToCartHeaderLinesOneText:this.props.resources.linesAddedToCartHeaderLinesOneText,linesAddedToCartHeaderLinesFormatText:this.props.resources.linesAddedToCartHeaderLinesFormatText,linesAddedToCartHeaderMessageText:this.props.resources.linesAddedToCartHeaderMessageText}}_generateItemAddedToCartDialogResources(){return{viewCartButtonText:this.props.resources.viewCartButtonText,orderTemplateCloseButtonText:this.props.resources.orderTemplateCloseButtonText,itemAddedToCartHeaderItemOneText:this.props.resources.itemAddedToCartHeaderItemOneText,itemAddedToCartHeaderItemFormatText:this.props.resources.itemAddedToCartHeaderItemFormatText,itemAddedToCartHeaderMessageText:this.props.resources.itemAddedToCartHeaderMessageText,freePriceText:this.props.resources.freePriceText,originalPriceText:this.props.resources.originalPriceText,currentPriceText:this.props.resources.currentPriceText}}_renderOrderTemplateActions(e){const{id:t,typeName:r,context:a,resources:s}=this.props,{addTemplateToBagButtonText:n,renameTemplateButtonText:i,deleteTemplateButtonText:o,closeWindowButtonText:l,addToCartFailureMessage:c,addToCartSuccessMessage:d,addToCartProcessMessage:u}=s,m={data:{orderTemplate:e},id:t,typeName:r,context:a,telemetryContent:this.telemetryContent,handlers:{onRenameTemplate:this._renameTemplate,onRemoveTemplate:this._removeTemplate},renameOrderTemplateDialogStrings:this._generateOrderTemplateNameDialogResources(s),resources:{addTemplateToBagButtonText:n,renameTemplateButtonText:i,deleteTemplateButtonText:o,addToCartFailureMessage:c,addToCartSuccessMessage:d,addToCartProcessMessage:u,closeWindowButtonText:l,linesAddedToCartDialogResources:this._generateLinesAddedToCartDialogResources()}};return Object(_.OrderTemplateActionsView)(m)}_generateOrderTemplateNameDialogResources(e){return{orderTemplateHeaderLabel:e.renameOrderTemplateTitleText,orderTemplateTitleLabel:e.orderTemplateTitle,orderTemplateNameAriaLabel:e.orderTemplateTitle,orderTemplateDescription:"",defaultOrderTemplateName:e.defaultOrderTemplateName,orderTemplateButtonLabel:e.renameOrderTemplateButtonText,orderTemplateCancelButtonLabel:e.cancelBtnLabel}}_isFirstPage(){return 0===this._getCurrentPageNumber()}_getCurrentPageNumber(){const e=this.props.config.itemsPerPage||50;return this.props.context.request.query&&+this.props.context.request.query.skip/e||0}_renderProductList(){var e;const{priceFree:t,originalPriceText:r,currentPriceText:a,addOrderTemplateItemToBagButtonText:s,removeItemFromOrderTemplateButtonText:n,productDimensionTypeColor:o,productDimensionTypeSize:l,productDimensionTypeStyle:c,inputQuantityAriaLabel:d,deleteButtonText:u}=this.props.resources,{context:m,telemetry:p}=this.props,{imageSettings:h}=this.props.config;return null===(e=this.state.productSelection)||void 0===e?void 0:e.map((e,g)=>{var y;const b={orderTemplateLine:e,productListLine:e.productListLine,price:null===(y=e.fullProduct)||void 0===y?void 0:y.ProductPrice,context:m,productUrl:e.fullProduct?Object(i.getProductUrlSync)(e.fullProduct.ProductDetails,m.actionContext,void 0):"",imageSettings:h,telemetry:p,moduleId:this.props.id,moduleTypeName:this.props.typeName,quantity:e.productListLine.Quantity,handlers:{onAddToBag:this._addItemToBag,onRemoveItem:this._removeItemFromOrderTemplateLines,onChangeQuantity:this._changeQuantity,onSelect:this.onSelect.bind(this)},resources:{productDimensionTypeColor:o,productDimensionTypeSize:l,productDimensionTypeStyle:c,freePriceText:t,originalPriceText:r,currentPriceText:a,inputQuantityAriaLabel:d,removeFromOrderTemplateLinesText:n,addToBagButtonText:s,deleteButtonText:u},index:g,isMobile:this.isMobile,toggleDetailsDisplayed:this._toggleDetailsDisplayed};return Object(_.OrderTemplateLineView)(b)})}_updateViewport(){this._viewport=this._getViewport()}};Object(n.__decorate)([b.n],S.prototype,"_viewport",void 0),Object(n.__decorate)([b.e],S.prototype,"isMobile",null),Object(n.__decorate)([b.d],S.prototype,"componentDidMount",null),S=Object(n.__decorate)([f.a],S),t.default=S},"E/MF":function(e,t,r){"use strict";var a=r("Ma3q");r.d(t,"Quantity",(function(){return a.a}));r("vdFq")},F8el:function(e,t,r){"use strict";r.r(t);r("9VTn");var a=r("rePB"),s=r("mrSG"),n=r("Hxoz"),i=r("hBpL"),o=r("xT9B"),l=r("TSYQ"),c=r.n(l),d=r("okNM"),u=r("cDcd"),m=r.n(u),p=r("HyYO");const h=e=>{const{ratingsSummary:t}=e,r=t.totalRatingsCount||0;return[g(e,5,t.star5Count,r),g(e,4,t.star4Count,r),g(e,3,t.star3Count,r),g(e,2,t.star2Count,r),g(e,1,t.star1Count,r)]},g=(e,t,r,a)=>{r=r||0;const s=0===(a=a||0)?0:r/a,i=new Intl.NumberFormat(e.locale,{style:"percent"}).format(s),o=Object(n.format)(e.resources.barItemAriaLabel,t,i);return{starLabel:m.a.createElement("span",{className:"ms-ratings-histogram__star"},t),percentage:m.a.createElement("span",{className:"ms-ratings-histogram__percentage"},i),bar:m.a.createElement(n.Progress,{value:100*s,max:100,ariaLabel:o,className:"ms-ratings-histogram__bar"}),buttonProps:{tag:"button",className:"ms-ratings-histogram__item",onClick:()=>{e.onClick(t)}}}},y=e=>m.a.createElement("p",{className:"ms-ratings-histogram__average"},e.summary.averageRating," / 5"),b=e=>m.a.createElement("p",{className:"ms-ratings-histogram__total"},e.summary.totalRatingsCount);function f(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,a)}return r}function T(e){for(var t=1;tthis.props.config.heading.text=e.target.value,this.selectFilterBy=this.selectFilterBy.bind(this)}render(){const{resources:e}=this.props,{className:t,heading:r}=this.props.config,{ratingsSummary:{result:a}}=this.props.data,s=a&&a.totalRatingsCount?""+a.totalRatingsCount:"0",l=c()("ms-ratings-histogram",t),d=T(T({},this.props),{},{className:l,callbacks:{selectFilterBy:this.selectFilterBy},moduleProps:{moduleProps:this.props,className:l},histogramItems:a?h({ratingsSummary:a,resources:T({},e),locale:this.props.context.request.locale,onClick:this.selectFilterBy}):[],averageRating:a&&u.createElement(i.n,{avgRating:a.averageRating,ratingCount:s,ariaLabel:Object(n.format)(this.props.resources.averageRatingAriaLabel,a.averageRating,"5"),readOnly:!0,context:this.props.context,hideCount:!0,id:this.props.id,typeName:this.props.typeName,data:{}}),averageNumber:a&&u.createElement(y,{summary:a}),totalReviews:a&&u.createElement(b,{summary:a}),ratingsSummaryProps:{className:"ms-ratings-histogram__summary"},heading:r&&u.createElement(o.Text,{className:"ms-ratings-histogram__heading",tag:r.tag||"h2",text:r.text,editProps:{onEdit:this.handleHeadingChange,requestContext:this.props.context.request}}),histogramProps:{className:"ms-ratings-histogram__histogram"}});return this.props.renderView(d)}selectFilterBy(e){const t=""+e;this.props.context.actionContext.update(Object(p.createRatingsReviewsStateInput)({filterKey:t}),{filterKey:t})}};_=Object(s.__decorate)([d.a],_);t.default=_},FFTj:function(e,t,r){"use strict";r.r(t);r("9VTn");var a=r("rePB"),s=(r("ES/9"),r("y/s1"),r("BDvt"),r("WVYb"),r("mrSG")),n=r("UdvX"),i=r("Hxoz"),o=r("xT9B"),l=r("2Mh4"),c=r("Y2vv"),d=r("TSYQ"),u=r.n(d),m=r("okNM"),p=r("cDcd"),h=r("8HEZ"),g=(r("LR6M"),r("hBpL"));const y=e=>{let{key:t,className:r,dimensionType:a,dimensionValue:s}=e;return p.createElement("div",{key:t,className:r},p.createElement("span",{className:"msc-wishlist-dimension__label"},a,":"),p.createElement("span",{className:"msc-wishlist-dimension__value"},s))},b=e=>{const{product:t,itemKey:r,handlers:a}=e,{onAddToCart:s}=a;s&&t&&r&&s(t,r)},f=e=>{const{onRemoveItem:t}=e.handlers,{RecordId:r}=e.product;t&&r&&t(r)},T=(e,t,r,a,s)=>{const n={viewports:{xs:{q:"w=315&h=315&m=6",w:0,h:0},lg:{q:"w=315&h=315&m=6",w:0,h:0},xl:{q:"w=315&h=315&m=6",w:0,h:0}},lazyload:!0,cropFocalRegion:!0};return s&&(s.cropFocalRegion=!0),r?p.createElement(o.Image,{className:"ms-wishlist-items__product-image",altText:t,title:t,src:r,fallBackSrc:a,gridSettings:e.request.gridSettings,imageSettings:s||n,loadFailureBehavior:"empty"}):null},_=e=>{const{price:t,context:r,moduleId:a,moduleTypeName:s,resources:n}=e;return t?p.createElement(g.k,{id:a,typeName:s,data:{price:t},className:"ms-wishlist-items__product-price",freePriceText:n.freePriceText,originalPriceText:n.originalPriceText,currentPriceText:n.currentPriceText,context:r}):null},C=e=>{const{product:t,resources:r}=e;return t&&t.Dimensions?t.Dimensions.map((e,a)=>{if(!e.DimensionValue||!e.DimensionValue.Value)return;let s="";switch(e.DimensionTypeValue){case 1:s=r.productDimensionTypeColor;break;case 3:s=r.productDimensionTypeSize;break;case 4:s=r.productDimensionTypeStyle;break;default:return}return p.createElement(y,{key:`${t.RecordId}-dimensions-${a}`,className:"msc-price ms-wishlist-items__product-dimension",dimensionType:s,dimensionValue:e.DimensionValue.Value})}):[]},v=e=>{const{product:t,price:r,context:a,resources:s}=e,{Name:n,Dimensions:i}=t,{productDimensionTypeColor:o,productDimensionTypeSize:l,productDimensionTypeStyle:c}=s;let d="Free",u=null;return r&&(d=0===r.BasePrice?s.freePriceText:a.cultureFormatter.formatCurrency(r.BasePrice,r.CurrencyCode)),i&&(u=i.map(e=>{switch(e.DimensionTypeValue){case 1:return`${o}${e.DimensionValue&&e.DimensionValue.Value}`;case 3:return`${l}${e.DimensionValue&&e.DimensionValue.Value}`;case 4:return`${c}${e.DimensionValue&&e.DimensionValue.Value}`;default:return""}})),`${n} ${d} ${u&&u.join("")||""}`},x=e=>{let{className:t,errorType:r,text:a}=e;switch(r){case"EMPTY":return p.createElement("p",{className:u()("ms-wishlist-items__message-empty",t)},a);case"FAILED":return p.createElement("p",{className:u()("ms-wishlist-items__message-failed",t)},a);case"LOADING":default:return p.createElement("p",{className:"ms-wishlist-items__message-waiting"},a)}};function S(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,a)}return r}function O(e){for(var t=1;tthis.props.config.heading.text=e.target.value,this._onDismiss=()=>{this.setState({isOpen:!1})},this._renderHeading=e=>{if(e)return p.createElement(o.Text,{className:"ms-wishlist-items__heading",tag:e.tag||"h2",text:e.text,editProps:{onEdit:this.handleHeadingChange,requestContext:this.props.context.request}})},this._addItemToCart=async(e,t)=>{const{context:r,data:a,resources:s,telemetry:i}=this.props,{cart:o,productAvailability:l}=a,{addedToCartSuccessMessage:d,addedToCartFailureMessage:u}=s,m=this._getProductInventory({ProductDetails:e},l.result);if(r&&o.result){var p,h,g,y,b,f,T;const a=(null===(p=this.props.data.featureState.result)||void 0===p||null===(h=p.find(e=>"Dynamics.AX.Application.RetailDefaultOrderQuantityLimitsFeature"===e.Name))||void 0===h?void 0:h.IsEnabled)||!1,s=null===(g=this.props.context)||void 0===g||null===(y=g.request)||void 0===y||null===(b=y.app)||void 0===b||null===(f=b.platform)||void 0===f?void 0:f.enableDefaultOrderQuantityLimits,l=this.props.data.customerInformation.result,_="all"===s||l&&("b2b"===s&&l.IsB2b||"b2c"===s&&!l.IsB2b),C=a&&_,v=null===(T=this.props.context.actionContext.requestContext.channel)||void 0===T?void 0:T.EmailDeliveryModeCode,x=await Object(c.h)({callerContext:this.props.context.actionContext,queryResultSettings:{}},[e.RecordId]),S={product:e,quantity:1,enableStockCheck:r.app.config.enableStockCheck,availableQuantity:m?m.ProductAvailableQuantity.AvailableQuantity:0,additionalProperties:{orderQuantityLimitsFeatureIsEnabled:C},isAddEmailDeliveryItemToCart:n.ArrayExtensions.hasElements(x)&&n.ArrayExtensions.hasElements(x[0].DeliveryOptions)&&x[0].DeliveryOptions[0].Code===v};o.result.addProductToCart(S).then(async r=>{if("SUCCESS"===r.status)this.setState({productId:e.RecordId,itemKey:t,userMessage:d,statusCssString:"success",messageGlyph:"fas fa-check",isOpen:!0});else if("MAXQUANTITY"===r.substatus){var a,s,n;const r=(null===(a=(await o).cart)||void 0===a||null===(s=a.CartLines)||void 0===s||null===(n=s.find(t=>t.ProductId===e.RecordId))||void 0===n?void 0:n.Quantity)||0,i=this._getInventoryValueMessage(m,r);this.setState({productId:e.RecordId,itemKey:t,userMessage:i,statusCssString:"danger",messageGlyph:"fas fa-exclamation-triangle",isOpen:!0})}else if("QUANTITYLIMITS"===r.substatus&&C){var i;const a=null===(i=r.errorDetails)||void 0===i?void 0:i.LocalizedMessage;this.setState({productId:e.RecordId,itemKey:t,userMessage:a||u,statusCssString:"danger",messageGlyph:"fas fa-exclamation-triangle",isOpen:!0})}else this.props.telemetry.debug("[wishlist-items] Unable to Update Cart Line from the wishlist"),this.setState({productId:e.RecordId,itemKey:t,userMessage:u,statusCssString:"danger",messageGlyph:"fas fa-exclamation-triangle",isOpen:!0})}).catch(r=>{i.warning(r),i.debug("[wishlist-items] Error trying to Update Cart Line from the wishlist"),this.setState({productId:e.RecordId,itemKey:t,userMessage:u,statusCssString:"danger",messageGlyph:"fas fa-exclamation-triangle",isOpen:!0})})}},this._removeItemFromWishlist=e=>{const{context:t,data:r,telemetry:a}=this.props,{wishlists:s}=r;if(t&&t.actionContext){const r=t.request.user.isAuthenticated&&t.request.user.token,n=this._getWishlistLineIdFromProductId(e);r&&s.result&&s.result[0]&&n?Object(l.e)({callerContext:t.actionContext},s.result[0].Id,[{LineId:n}]).then(e=>{const r=e;r&&r.Id&&t.request.user.isAuthenticated&&(t.actionContext.update(Object(l.c)({},null),[r]),Object(h.default)(new h.ActiveWishlistInput,t.actionContext).then(e=>{const r=e;r&&r.length>0&&t.actionContext.update(new h.ActiveWishlistInput,r)}).catch(e=>{a.warning("[wishlist-items] Unable to hyderate the wishlist with product information"),a.error(e)}))}).catch(e=>{a.warning("[wishlist-items] Unable remove items from the wishlist"),a.error(e)}):a.warning("[wishlist-items] Unable remove items from the wishlist user token or lineItemID wasn't found")}},this._inventoryLabel=e=>{const{productAvailability:t}=this.props.data;if(t&&t.result){const r=this._getProductInventory(e,t.result);if(r)return r.StockLevelLabel}},this._inventoryClassName=e=>{const{productAvailability:t}=this.props.data;if(t&&t.result){const r=this._getProductInventory(e,t.result);if(r&&r.StockLevelCode)return"ms-wishlist-items__"+r.StockLevelCode.toLowerCase()}},this._isProductInStock=e=>{const{data:t,context:r}=this.props,{productAvailability:a}=t;if(!r.app.config.enableStockCheck)return!0;if(!a.result||!e.ProductDetails)return!1;for(const s of a.result)if(s.ProductAvailableQuantity&&s.ProductAvailableQuantity.ProductId&&s.ProductAvailableQuantity.ProductId===e.ProductDetails.RecordId)return s.IsProductAvailable;return!1},this._getWishlistLineIdFromProductId=e=>{const{wishlists:t}=this.props.data;if(!(t.result&&t.result.length>0&&t.result[0].CommerceListLines&&t.result[0].CommerceListLines.length>0))return this.props.telemetry.error("Wishlist content is empty, module wont render."),null;const r=t.result[0].CommerceListLines.filter(t=>t.ProductId===e);return r&&r[0].LineId?r[0].LineId:null},this.telemetryContent=Object(i.getTelemetryObject)(this.props.context.request.telemetryPageName,this.props.friendlyName,this.props.telemetry)}async componentDidMount(){this.setState({})}render(){const{heading:e,className:t}=this.props.config,{emptyWishlistText:r,wishlistErrorGettingWishlist:a}=this.props.resources,{cart:s,productAvailability:n,wishlists:i,products:o}=this.props.data;if("LOADING"===s.status||"LOADING"===n.status||"LOADING"===i.status){const r=O(O({},this.props),{},{WishlistItems:{moduleProps:this.props,className:u()("ms-wishlist-items",t)},status:"LOADING",statusMessage:p.createElement(x,{errorType:"LOADING",text:"Loading..."}),heading:this._renderHeading(e)});return this.props.renderView(r)}if("FAILED"===s.status||"FAILED"===n.status||"FAILED"===i.status){const r=O(O({},this.props),{},{WishlistItems:{moduleProps:this.props,className:u()("ms-wishlist-items",t)},status:"FAILED",statusMessage:p.createElement(x,{errorType:"FAILED",text:a}),heading:this._renderHeading(e)});return this.props.renderView(r)}const l=o&&o.result;if(l&&0===l.length){const a=O(O({},this.props),{},{WishlistItems:{moduleProps:this.props,className:u()("ms-wishlist-items",t)},status:"EMPTY",statusMessage:p.createElement(x,{errorType:"EMPTY",text:r}),heading:this._renderHeading(e)});return this.props.renderView(a)}const c=O(O({},this.props),{},{WishlistItems:{moduleProps:this.props,className:u()("ms-wishlist-items",t)},status:"SUCCESS",heading:this._renderHeading(e),Products:{className:"ms-wishlist-items__products",tag:"ul"},Product:{className:"ms-wishlist-items__product",tag:"li"},ProductDetails:{className:"ms-wishlist-items__product-link",tag:"a"},telemetryContent:this.telemetryContent,ProductDimensions:{className:"ms-wishlist-items__product-dimensions"},products:l&&this._renderProductList(l)});return this.props.renderView(c)}_renderProductList(e){const{priceFree:t,originalPriceText:r,currentPriceText:a,addToCartButtonText:s,outOfStockText:o,removeButtonText:l,productDimensionTypeColor:c,productDimensionTypeSize:d,productDimensionTypeStyle:u,productDimensionTypeAmount:m}=this.props.resources,{context:h,telemetry:g}=this.props,{imageSettings:y,enableImageProductLink:x}=this.props.config;return e.map((e,S)=>(e=>{const{product:t,productUrl:r,price:a,context:s,imageSettings:o,isInStock:l,removeFromWishlistText:c,addToCartText:d,outOfStockText:u,wishlistState:m,itemKey:h,handlers:g,enableImageProductLink:y,inventoryInformationLabel:x,inventoryLabelClassName:S,telemetryContent:O}=e;if(!t)return null;const{RecordId:P,Name:N,PrimaryImageUrl:E,Dimensions:L}=t,{onDismiss:I}=g,D=S?"ms-wishlist-items__inventory-label "+S:"ms-wishlist-items__inventory-label",w=Object(n.getFallbackImageUrl)(t.ItemId,s.actionContext.requestContext.apiSettings),k=Object(i.getPayloadObject)("click",O,"",P.toString()),A=Object(i.getTelemetryAttributes)(O,k),B=2===t.ItemTypeValue;return{key:P+"-item",productImage:E&&N&&T(s,t.Name,E,w,o),productLink:r&&p.createElement("a",Object.assign({href:r,className:"ms-wishlist-items__product-link"},A,{"aria-label":v(e)}),N),productDimensions:L&&C(e),productPrice:a&&_(e),entireProductLink:y?r:void 0,productAriaLabel:y?v(e):void 0,productName:y&&p.createElement("div",{className:"ms-wishlist-items__product-title"},N),addToCartButton:p.createElement(i.Button,{className:"ms-wishlist-items__product-add-button",title:(B||l)&&d||u,onClick:t=>b(e),disabled:!(B||l)},(B||l)&&d||u),inventoryInformation:x&&p.createElement("span",{className:D},x),removeButton:p.createElement("button",{className:"ms-wishlist-items__product-remove-button","aria-label":c,onClick:t=>f(e)}),productStatusMessage:m&&m.isOpen&&m.productId===P&&m.itemKey===h&&p.createElement("div",{className:"ms-wishlist-items__product-status"},p.createElement(i.Alert,{color:m.statusCssString,isOpen:m.isOpen,toggle:I},p.createElement("span",null,m.userMessage)))}})({product:e.ProductDetails,price:e.ProductPrice,context:h,wishlistState:this.state,productUrl:Object(n.getProductUrlSync)(e.ProductDetails,h.actionContext,void 0),imageSettings:y,removeFromWishlistText:l,isInStock:this._isProductInStock(e),addToCartText:s,outOfStockText:o,index:S,itemKey:`${e.ProductDetails.RecordId}-${e.ProductDetails.ItemId}-${S}`,telemetry:g,moduleId:this.props.id,moduleTypeName:this.props.typeName,enableImageProductLink:x,inventoryInformationLabel:this._inventoryLabel(e),inventoryLabelClassName:this._inventoryClassName(e),telemetryContent:this.telemetryContent,handlers:{onAddToCart:this._addItemToCart,onRemoveItem:this._removeItemFromWishlist,onDismiss:this._onDismiss},resources:{productDimensionTypeColor:c,productDimensionTypeSize:d,productDimensionTypeStyle:e.ProductDetails.IsGiftCard?m:u,freePriceText:t,originalPriceText:r,currentPriceText:a}}))}_getInventoryValueMessage(e,t){const{context:r,resources:a}=this.props,{maxQuantityLimitText:s}=a,n=r.app.config.maxQuantityForCartLineItem||10;if(!e||!e.ProductAvailableQuantity.AvailableQuantity||!r.app.config.enableStockCheck)return s.replace("{maxQuantity}",n.toString()).replace("{curQuantity}",t.toString());const i=Math.min(n,e.ProductAvailableQuantity.AvailableQuantity);return s.replace("{maxQuantity}",i.toString()).replace("{curQuantity}",t.toString())}_getProductInventory(e,t){if(t&&t.length)for(const r of t)if(e.ProductDetails.RecordId===r.ProductAvailableQuantity.ProductId)return r}};P=Object(s.__decorate)([m.a],P);t.default=P},I3lq:function(e,t,r){"use strict";r.r(t);var a=r("rePB"),s=(r("ES/9"),r("9VTn"),r("mrSG")),n=r("UdvX"),i=r("Hxoz"),o=r("xT9B"),l=r("OtQ+"),c=r("Y2vv"),d=r("TSYQ"),u=r.n(d),m=r("2vnA"),p=r("okNM"),h=r("cDcd"),g=r.n(h),y=r("gtO6"),b=r("6jQD"),f=(r("eEtD"),r("Q81S"),r("N8Sx"));const T=e=>{let{text:t,className:r,href:a,ariaLabel:s}=e;return h.createElement("a",{className:r,href:a,"aria-label":s}," ",t," ")};var _=r("hBpL");const C=e=>{let{products:t,context:r,imageSettings:a,resources:s,moduleType:n,moduleId:i,allowBackNavigation:o,telemetryContent:l}=e;return h.createElement("ul",{className:"list-unstyled"},t.map((e,t)=>h.createElement("li",{className:"ms-product-search-result__item",key:t},h.createElement(_.l,{context:r,telemetryContent:l,imageSettings:a,freePriceText:s.priceFree,originalPriceText:s.originalPriceText,currentPriceText:s.currentPriceText,ratingAriaLabel:s.ratingAriaLabel,allowBack:o,id:i,typeName:n,data:{product:e}}))))};r("WVYb"),r("LR6M");const v=e=>{let{product:t,context:r,imageSettings:a,resources:s,telemetryContent:l}=e;if(null===t)return null;const c=t.Name,d=t&&t.RecordId?t.RecordId:0,u=Object(n.getProductPageUrlSync)(t.Name||"",d,r&&r.actionContext,void 0),m=Object(n.getFallbackImageUrl)(t.ItemId,r.actionContext.requestContext.apiSettings),p=Object(i.getPayloadObject)("click",l,c,d.toString()),g=Object(i.getTelemetryAttributes)(l,p);return h.createElement("div",{className:"ms-feature-search-result__item"},h.createElement("a",Object.assign({href:u,onClick:Object(i.onTelemetryClick)(l,p,t.Name)},g,{"aria-label":t.Name}),h.createElement("div",{className:"msc-feature-search-result__item__image"},function(e,t,r,a,s){if(!r||!t||!e)return null;const n={src:r,altText:a||""},i={gridSettings:t,imageSettings:e,fallBackSrc:s};return h.createElement(o.Image,Object.assign({},n,i,{loadFailureBehavior:"empty"}))}(a,r.request.gridSettings,t.PrimaryImageUrl,t.Name,m))),h.createElement("div",{className:"msc-feature-search-result__item__detail"},h.createElement("p",{className:"msc-feature-search-result__item__heading"},s.featureSimilarLooksTitle),(y=null==t?void 0:t.Name,h.createElement("h1",{className:"msc-feature-search-result__item__product-title"},y))));var y};const x=e=>{let{text:t,className:r}=e;return h.createElement("span",{className:r}," ",t," ")},S=e=>{let{separator:t}=e;return h.createElement("span",null," ",t," ")};r("y/s1"),r("BDvt");var O=r("sEfC"),P=r.n(O);function N(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,a)}return r}function E(e){for(var t=1;tD(e,t))}function D(e,t){return t.RefinerRecordId===e.RefinerRecordId&&t.RefinerSourceValue===e.RefinerSourceValue&&t.DataTypeValue===e.DataTypeValue&&(L(t.DataTypeValue)||t.LeftValueBoundString===e.LeftValueBoundString)}function w(e,t){const r=[];let a=!1;if(t.forEach(t=>{if(D(e.productRefinerValue,t)){if(a=!0,e.isSelecting){const a=E(E({},t),{},{LeftValueBoundString:void 0!==e.rangeStart&&""+e.rangeStart||t.LeftValueBoundString,RightValueBoundString:void 0!==e.rangeEnd&&""+e.rangeEnd||t.RightValueBoundString});r.push(a)}}else r.push(t)}),!a){const t=E(E({},e.productRefinerValue),{},{LeftValueBoundString:void 0!==e.rangeStart&&""+e.rangeStart||e.productRefinerValue.LeftValueBoundString,RightValueBoundString:void 0!==e.rangeEnd&&""+e.rangeEnd||e.productRefinerValue.RightValueBoundString});r.push(t),5!==e.productRefinerValue.DataTypeValue&&6!==e.productRefinerValue.DataTypeValue||0!==e.parentProductRefinerHierarchy.RefinerTypeValue||e.parentProductRefinerHierarchy.Values.forEach(e=>{if(e.RefinerRecordId===t.RefinerRecordId&&e.LeftValueBoundString===t.LeftValueBoundString);else{const t=r.findIndex(t=>D(e,t));t>-1&&r.splice(t,1)}})}return r}let k=class extends h.Component{constructor(e){super(e),this._formattedPriceReverseLookup=new Map,this._onRangeUpdate=this._onRangeUpdate.bind(this),this._onRangeUpdateEnd=this._onRangeUpdateEnd.bind(this),this._handleRangeTooltipText=this._handleRangeTooltipText.bind(this),this._changeMin=this._changeMin.bind(this),this._changeMax=this._changeMax.bind(this),this._finishChangeMin=this._finishChangeMin.bind(this),this._finishChangeMax=this._finishChangeMax.bind(this),this.minInput=h.createRef(),this.maxInput=h.createRef();const{selectedRefinementCriterion:t}=this.props,r=t&&t.LeftValueBoundString||"0",a=t&&t.RightValueBoundString||void 0;this.state={isChecked:!1,validationErrorMin:void 0,validationErrorMax:void 0,selectedMin:r,selectedMax:a,touchedMin:!1,touchedMax:!1}}get currencyCode(){return this.props.productRefinerValue.UnitText||""}render(){const{productRefinerValue:e,parentProductRefinerHierarchy:t,refineItemCommonProps:r}=this.props;if(e&&t)return"input"===this.props.rangeType?this._renderInputFields():this._renderSlider();r.telemetry.error("Cannot render refine value range without productRefinerValue and parentProductRefinerHierarchy")}_renderInputFields(){const{isDisabled:e,parentProductRefinerHierarchy:t,refineItemCommonProps:r}=this.props,{selectedMin:a,selectedMax:s,touchedMin:n,touchedMax:i,validationErrorMin:o,validationErrorMax:l}=this.state,c={"aria-label":(r.rangeNameFormat||"{0}").replace("{0}",t.KeyName||""),"aria-disabled":e},d="ms-refine-submenu__input-range refine-submenu__input-range-min "+(o?"refine-submenu__input-range--error":""),u="ms-refine-submenu__input-range refine-submenu__input-range-max "+(l?"refine-submenu__input-range--error":""),m=this._getFormattedSelectedValue(a,n,o),p=this._getFormattedSelectedValue(s,i,l);return h.createElement("form",Object.assign({className:"ms-refine-submenu__input-range-refiner"},c),h.createElement("label",{className:"ms-refine-submenu__input-range-label refine-submenu__input-range-label-min"},r.minLabel,h.createElement("input",{className:d,onChange:this._changeMin,onFocus:this._changeMin,onBlur:this._finishChangeMin,value:m,ref:this.minInput})),h.createElement("label",{className:"ms-refine-submenu__input-range-label refine-submenu__input-range-label-max"},r.maxLabel,h.createElement("input",{className:u,placeholder:p?void 0:r.placeholderTextMax,onChange:this._changeMax,onFocus:this._changeMax,onBlur:this._finishChangeMax,value:p,ref:this.maxInput})),o&&h.createElement("span",{className:"ms-refine-submenu__input-range-error-text refine-submenu__input-range-min-error-text"},o),l&&o!==l&&h.createElement("span",{className:"ms-refine-submenu__input-range-error-text refine-submenu__input-range-max-error-text"},l))}_renderSlider(){const{isDisabled:e,productRefinerValue:t,parentProductRefinerHierarchy:r,selectedRefinementCriterion:a}=this.props,s=t.LeftValueBoundString,n=t.RightValueBoundString,o=a&&a.LeftValueBoundString||t.LeftValueBoundString||"0",l=a&&a.RightValueBoundString||t.RightValueBoundString||n,c=`slider_${r.RecordId}_${t.RefinerRecordId}`,d={"aria-disabled":e},u=this._formatPrice(s),m=this._formatPrice(n),p=this._formatPrice(o),g=this._formatPrice(l);return h.createElement(i.Slider,Object.assign({className:"ms-refine-submenu__range-refiner",key:c,id:c,inForm:!1,min:s&&Number(s)||void 0,max:n&&Number(n)||void 0,step:1,orientation:"horizontal",labels:[{labelId:c+"_start",labelString:""+u,labelPositioning:"start"},{labelId:c+"_end",labelString:""+m,labelPositioning:"end"}],showLabels:!0,showTooltip:!0,sliderThumbs:[{id:c+"_slider_thumb_start",value:o&&Number(o)||0,ariaLabel:`${this.props.minValueSliderThumbAriaLabel} ${this.currencyCode}`,ariaValueText:""+p},{id:c+"_slider_thumb_end",value:Number(l)||Number(m),ariaLabel:`${this.props.maxValueSliderThumbAriaLabel} ${this.currencyCode}`,ariaValueText:""+g}],onChangeEnd:this._onRangeUpdateEnd,onChange:P()(this._onRangeUpdate,500),handleTooltipText:this._handleRangeTooltipText},d))}_changeMin(e){this._changeValue(e,"Min")}_changeMax(e){this._changeValue(e,"Max")}_changeValue(e,t){const r="selected"+t,a="touched"+t;this.setState({[r]:this._getInputWithoutFormatting(e.currentTarget.value),[a]:!0})}_finishChangeMin(e){const t=this._getInputWithoutFormatting(e.currentTarget.value);this.setState({selectedMin:t,minTouched:!1});const r=Number(t),{onToggle:a,parentProductRefinerHierarchy:s,productRefinerValue:n,refineItemCommonProps:i,selectedRefinementCriterion:o}=this.props,l=o&&o.RightValueBoundString||void 0,c=l?Number(l):void 0;return isNaN(r)?(this.setState({validationErrorMin:i.validationErrorNaN}),this._focus("Min"),!1):this._validateRange(r,c)?(a({parentProductRefinerHierarchy:s,productRefinerValue:n,isSelecting:!0,rangeStart:r,rangeEnd:c}),!0):(this._focus("Min"),!1)}_finishChangeMax(e){const t=this._getInputWithoutFormatting(e.currentTarget.value);this.setState({selectedMax:t,maxTouched:!1});const r=Number(t),{onToggle:a,parentProductRefinerHierarchy:s,productRefinerValue:n,refineItemCommonProps:i,selectedRefinementCriterion:o}=this.props,l=o&&o.LeftValueBoundString||"0",c=Number(l);return isNaN(r)?(this.setState({validationErrorMax:i.validationErrorNaN}),this._focus("Max"),!1):!!this._validateRange(c,r)&&(n?a({parentProductRefinerHierarchy:s,productRefinerValue:n,isSelecting:!0,rangeStart:c,rangeEnd:r}):this._focus("Max"),!0)}_focus(e){const t="Max"===e?this.maxInput:this.minInput;setTimeout(()=>{t&&t.current&&t.current.focus()},50)}_getFormattedSelectedValue(e,t,r){return t||r||void 0===e?e:this._formatPrice(e)}_validateRange(e,t){const{refineItemCommonProps:r}=this.props;return void 0===t||(!(e>t)||(this.setState({validationErrorMin:r.validationErrorRange,validationErrorMax:r.validationErrorRange}),!1))}_formatPrice(e){const t=this.props.refineItemCommonProps.locale,r=function(e,t,r,a){if(!e||!t)return a.trace(`[refine-menu.utilities.formatPrice] could not format price for ${e} ${t}`),e||"";const s=e&&Number(e)||0;let n;try{n=new Intl.NumberFormat(r,{style:"currency",currencyDisplay:"symbol",currency:t,minimumFractionDigits:0}).format(s)}catch(i){n=`${s} ${t}`,a.warning(`[refine-menu.utilities.formatPrice] Failed to format price for ${n}: ${i}`)}return n}(e,this.currencyCode,t,this.props.refineItemCommonProps.telemetry);return void 0===e||this._formattedPriceReverseLookup.has(r)||this._formattedPriceReverseLookup.set(r,e),r}_getInputWithoutFormatting(e){const t=Number(e);if(!isNaN(t))return e;return this._formattedPriceReverseLookup.get(e)||e}_onRangeUpdate(e){if("mousemove"!==e.eventType){const{onToggle:t,parentProductRefinerHierarchy:r,productRefinerValue:a}=this.props;a&&e&&(t({parentProductRefinerHierarchy:r,productRefinerValue:a,isSelecting:!0,rangeStart:e.firstThumbValue,rangeEnd:e.secondThumbValue}),this._focusOnSliderThumb(e))}}_onRangeUpdateEnd(e){const{onToggle:t,parentProductRefinerHierarchy:r,productRefinerValue:a}=this.props;a&&e&&(t({parentProductRefinerHierarchy:r,productRefinerValue:a,isSelecting:!0,rangeStart:e.firstThumbValue,rangeEnd:e.secondThumbValue}),this._focusOnSliderThumb(e))}_focusOnSliderThumb(e){if(e.id){const t=document.getElementById(e.id+"range");t&&setTimeout(()=>{t.focus()},0)}}_handleRangeTooltipText(e){return this._formatPrice(""+e)}};Object(s.__decorate)([m.e],k.prototype,"currencyCode",null),k=Object(s.__decorate)([p.a],k);var A=k,B=r("Ff2n");class M extends h.Component{constructor(e){super(e),this._onClick=e=>{e.preventDefault();const{parentProductRefinerHierarchy:t,productRefinerValue:r,selectedRefinementCriterion:a}=this.props;r&&(this.props.onToggle({parentProductRefinerHierarchy:t,productRefinerValue:r,isSelecting:!a}),setTimeout(()=>{this.anchorType.current&&this.anchorType.current.focus()},0))},this._onClick=this._onClick.bind(this),this.state={isChecked:!!this.props.selectedRefinementCriterion},this.anchorType=h.createRef(),this.payLoad=Object(i.getPayloadObject)("click",this.props.telemetryContent,"")}render(){const e=this.props,{isDisabled:t,refineItemCommonProps:r,parentProductRefinerHierarchy:a,productRefinerValue:s,selectedRefinementCriterion:n,index:o,children:l,onToggle:c,context:d,telemetryContent:u}=e,m=Object(B.a)(e,["isDisabled","refineItemCommonProps","parentProductRefinerHierarchy","productRefinerValue","selectedRefinementCriterion","index","children","onToggle","context","telemetryContent"]);if(!s)return void r.telemetry.error("[refine-item] Cannot render refineItem without productRefinerValue");s.LeftValueBoundString||r.telemetry.warning("[refine-item] RefineItem without LeftValueBoundString: "+JSON.stringify(s));const p=0===a.RefinerTypeValue;let g=p?"single-select":"multi-select";g="ms-refine-submenu-item "+g;const y=p?"radio":"checkbox",b=!!n;if(g=b?g+"-checked":g,4!==a.SourceValue){this.payLoad.contentAction.etext=s.LeftValueBoundLocalizedString||s.LeftValueBoundString;const e=Object(i.getTelemetryAttributes)(u,this.payLoad);return h.createElement("li",{className:"ms-refine-submenu-item",id:`${a.KeyName}_${o}`},h.createElement("a",Object.assign({key:n?"true":"false",ref:this.anchorType,href:this._getRefinerUrl(),tabIndex:0,onClick:this._onClick,className:g,role:y,"aria-checked":!!n},e,m),h.createElement("span",{className:"ms-refine-submenu-item__label"},s.LeftValueBoundLocalizedString||s.LeftValueBoundString,void 0!==s.Count&&` (${s.Count})`)))}if(s.LeftValueBoundString){var f,T;this.payLoad.contentAction.etext=s.LeftValueBoundLocalizedString;const e=Object(i.getTelemetryAttributes)(u,this.payLoad),t=parseInt(s.LeftValueBoundString,10),r=null===(f=this.props.selectedRefinerValues)||void 0===f?void 0:f.find(e=>e.DataTypeValue===s.DataTypeValue),n=parseInt((null==r?void 0:r.LeftValueBoundString)||"0",10);let l="ms-rating-component";return l+=t>n?"__up":t{e.preventDefault(),e.stopPropagation();const t=e.currentTarget,r=t.getAttribute("class").indexOf("choice-summary__clear-all")>-1,a=r?void 0:this._getSelectedRefinerChoice(t);this.props.onChoiceClicked&&this.props.onChoiceClicked({clearAll:r,itemClicked:t,choiceClicked:a,nextItemToFocus:t.nextSibling})},this.payLoad=Object(i.getPayloadObject)("click",this.props.telemetryContent,"")}get selectedRefinersMap(){const{selectedChoices:e}=this.props;return e.map(e=>({key:this._getKeyForRefinerValue(e),value:e}))}render(){const{clearAllText:e,label:t,classNames:r,choiceAriaLabel:a}=this.props,s=this.selectedRefinersMap;this.payLoad.contentAction.etext=e;const n=Object(i.getTelemetryAttributes)(this.props.telemetryContent,this.payLoad);return h.createElement("div",{className:"msc-choice-summary"},s.length>0&&t&&h.createElement("span",{className:"msc-choice-summary__label"},t),h.createElement("ul",{className:u()(r,"msc-choice-summary__list","list-unstyled")},s.map((e,t)=>{const r={"aria-posinset":t,"aria-setsize":s.length};this.payLoad.contentAction.etext=e.key;const n=Object(i.getTelemetryAttributes)(this.props.telemetryContent,this.payLoad);return h.createElement("li",Object.assign({className:"msc-choice-summary__list-item",key:e.key},r),h.createElement("a",Object.assign({className:"msc-choice-summary__item",href:this.props.urlBuilder(e.value,!1),"aria-label":`${e.key} ${a}`,onClick:this._onClick},n),e.key,h.createElement("span",{className:this.closeButtonGlyph+" msc-choice-summary__glyph"})))})),s.length>0&&e&&h.createElement("a",Object.assign({href:this.props.urlBuilder({},!0),className:"msc-choice-summary__clear-all"},n,{onClick:this._onClick}),e))}_getKeyForRefinerValue(e){const{choiceFormat:t,choiceRangeValueFormat:r,refinerHierarchy:a,telemetry:s}=this.props,n=t||"{1}",i=r;let o,l="";if(a&&a.find){const t=a.find(t=>!!t.Values.find(t=>D(t,e)));t?l=t.KeyName||"":s.warning("[choice-summary] could not find parent of selected refiner value")}return o=L(e.DataTypeValue)?i.replace("{0}",this._formatPrice(e.LeftValueBoundString,e.UnitText)).replace("{1}",this._formatPrice(e.RightValueBoundString,e.UnitText)):e.LeftValueBoundLocalizedString||e.LeftValueBoundString||"",n.replace("{0}",l).replace("{1}",o)}_formatPrice(e,t){if(!e||!t)return this.props.telemetry.trace("[choice-summary] could not format price"),e||"";const r=e&&Number(e)||0,a=j()(this.props,"context.request.locale","en-US");let s;try{s=new Intl.NumberFormat(a,{style:"currency",currencyDisplay:"symbol",currency:t,minimumFractionDigits:0}).format(r)}catch(n){s=`${r} ${t}`,this.props.telemetry.warning(`Failed to format price for ${s}: ${n}`)}return s}_getSelectedRefinerChoice(e){const t=this.selectedRefinersMap.find(t=>(e.innerText&&e.innerText.trim())===t.key);return t&&t.value||void 0}};Object(s.__decorate)([m.e],V.prototype,"selectedRefinersMap",null),V=Object(s.__decorate)([p.a],V);var F=V;const q=e=>{const{text:t,onClick:r,ariaLabel:a,innerRef:s,id:n}=e;return g.a.createElement("button",{id:n,className:"msc-button","aria-label":a,onClick:r,ref:s},t)},U=e=>g.a.createElement(i.Modal,{autoFocus:!0,applicationNode:"renderPage",returnFocusRef:e.returnRef,isOpen:e.isOpen,toggle:e.onModalToggle,className:"msc-search-result-modal",zIndex:1050}),H=e=>g.a.createElement(i.ModalHeader,{toggle:e.onModalToggle},e.resources.modalTitle),Q=e=>g.a.createElement(i.ModalFooter,null,g.a.createElement(i.Button,{onClick:e.onModalToggle,className:"ms-sort-and-filter-modal-close"},e.resources.modalCloseButtonText));class W extends h.Component{constructor(e){super(e),this._onToggleItem=this._onToggleItem.bind(this),this._onToggleSubmenu=this._onToggleSubmenu.bind(this);const t=this.props.isExpandedOnInitialLoad;this.state={expanded:t}}render(){const{productRefinerHierarchy:e,refineItemCommonProps:t}=this.props;return e||t.telemetry.error("Cannot render submenu without refiner hierarchy data"),4===e.SourceValue&&this.props.context.app.config.hideRating?null:h.createElement("div",{className:"ms-refine-submenu list-group "+e.KeyName},h.createElement(i.Button,{className:this.state.expanded?"ms-refine-submenu__toggle_expanded":"ms-refine-submenu__toggle_collapsed","aria-label":e.KeyName||"refiner.Name",onClick:this._onToggleSubmenu,"aria-expanded":this.state.expanded},e.KeyName),h.createElement(i.Collapse,{isOpen:this.state.expanded,timeout:350},this._renderChildItems(e)))}_renderChildItems(e){return L(e.DataTypeValue)?this._renderRange(e):this._renderSingleMultiSelect(e)}_renderSingleMultiSelect(e){const{isDisabled:t,refineItemCommonProps:r,selectedRefinerValues:a,context:s}=this.props,n=0===e.RefinerTypeValue&&4===e.SourceValue?{role:"radiogroup"}:void 0,i=e.Values||[],o=i.map((n,o)=>{if(!n)return r.telemetry.error(`[refine-submenu] Could not render refine item for refiner ${e.RecordId} (${e.KeyName})`),null;const l=I(n,a);return h.createElement(M,{parentProductRefinerHierarchy:e,productRefinerValue:n,selectedRefinementCriterion:l,selectedRefinerValues:a.filter(e=>i.find(t=>t.RefinerRecordId===e.RefinerRecordId)),refineItemCommonProps:r,onToggle:this._onToggleItem,urlBuilder:this.props.urlBuilder,isDisabled:t,key:o,index:o,context:s,moduleId:this.props.moduleId,moduleTypeName:this.props.moduleTypeName,telemetryContent:this.props.telemetryContent})});return h.createElement("ul",Object.assign({className:"ms-refine-submenu__list "+e.KeyName},n,{"aria-label":e.KeyName}),o)}_getRangeType(e){return 3===e.DisplayTemplateValue||1===e.DisplayTemplateValue||2===e.DisplayTemplateValue?"slider":"input"}_renderRange(e){const{isDisabled:t,refineItemCommonProps:r,selectedRefinerValues:a,context:s,minValueSliderThumbAriaLabel:n,maxValueSliderThumbAriaLabel:i}=this.props,o=(e.Values||[]).map((o,l)=>{if(!o)return r.telemetry.error(`Could not render refine item for refiner ${e.RecordId} (${e.KeyName})`),null;const c=I(o,a),d=this._getRangeType(e),u=c?`${c.LeftValueBoundString}-${c.RightValueBoundString}`:"not-selected-"+l;return h.createElement("li",{className:"ms-refine-submenu__item list-group-item refine-submenu__item--range",key:l},h.createElement(A,{parentProductRefinerHierarchy:e,productRefinerValue:o,selectedRefinementCriterion:c,refineItemCommonProps:r,onToggle:this._onToggleItem,urlBuilder:this.props.urlBuilder,isDisabled:t,rangeType:d,key:u,context:s,minValueSliderThumbAriaLabel:n,maxValueSliderThumbAriaLabel:i,moduleId:this.props.moduleId,moduleTypeName:this.props.moduleTypeName}))});return h.createElement("ul",{className:"ms-refine-submenu__list list-unstyled "+e.KeyName},o)}_onToggleItem(e){this.props.onUpdateRefiners(e)}_onToggleSubmenu(){this.setState(e=>({expanded:!e.expanded}))}}var G=W;const $=e=>{let{text:t}=e;return h.createElement("span",{className:"ms-search-result-container__no-results-message"},h.createElement("h5",{className:"error-text"}," ",t," "))};function z(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,a)}return r}function K(e){for(var t=1;t{let e=this.props.data.listPageState.result&&this.props.data.listPageState.result.activeProducts||[];const t=n.ArrayExtensions.hasElements(e)?e.map(e=>e.RecordId):[],r={ChannelId:this.props.context.request.apiSettings.channelId,CatalogId:this.props.context.request.apiSettings.catalogId},a=[],s=new n.GetCustomerInput(this.props.context.actionContext.requestContext.apiSettings),i=await Object(n.getCustomer)(s,this.props.context.actionContext);i&&i.CustomerAffiliations&&i.CustomerAffiliations.forEach(e=>{const t={AffiliationId:e.RetailAffiliationId,CustomerId:i.AccountNumber};a.push(t)}),await Object(c.c)({callerContext:this.props.context.actionContext,queryResultSettings:{}},r,t,new Date,null,a,!0).then(t=>{this.productPrices=t,e=e.map(e=>{const r=t.find(t=>t.ProductId===e.RecordId);var a;r&&(e.Price=null!==(a=r.CustomerContextualPrice)&&void 0!==a?a:e.Price,e.BasePrice=Math.max(r.BasePrice||0,r.TradeAgreementPrice||0,r.AdjustedPrice||0));return e}),this.props.data.listPageState.then(t=>{t.activeProducts=e})}).catch(e=>{throw this.props.context.actionContext.trace(e.message),this.props.context.actionContext.telemetry.exception(e),this.props.context.actionContext.telemetry.debug("[get Affiliation based price on search result container ]Error executing action"),new Error("[get Affiliation based price on search result container]Error executing action")})},this._getSearchResultModal=()=>{const{resources:e}=this.props;return(e=>({modal:U(e),modalHeader:H(e),modalFooter:Q(e),modalBody:g.a.createElement(i.ModalBody,{className:"msc-review-modal-body"})}))({resources:{modalCloseButtonText:e.modalCloseButtonText,modalTitle:e.modalTitle},isOpen:this.state.modalIsOpen,returnRef:this._modalToggleRef,onModalToggle:this._toggleModal})},this._getCollectionTitle=()=>{const{data:e,context:t,resources:r}=this.props;let a="";a=t&&t.request&&t.request.query&&t.request.query.q?`"${t.request.query.q}"`:e.category.result&&Y.getFriendlyName(t.request.locale,e.category.result.NameTranslations)||e.category.result&&e.category.result.Name;let s,n="";e.listPageState&&e.listPageState.result&&void 0!==e.listPageState.result.totalProductCount?s=e.listPageState.result.totalProductCount:e.products&&e.products.result&&(s=e.products.result.count),n=s&&0!==s?1!==s?Object(l.format)(this.props.resources.numberOfProducts,s):this.props.resources.oneProduct:Object(l.format)(this.props.resources.numberOfProducts,0);return{TitleContainer:{className:"ms-search-result-container__title"},title:{titlePrefix:h.createElement(x,{className:"ms-search-result__collection-title-prefix",text:r.searchTextPrefix}),titleText:a&&h.createElement(x,{className:"ms-search-result__collection-title-text",text:a}),titleCount:h.createElement(x,{className:"ms-search-result__collection-title-count",text:n})}}},this._getCategoryHierarchy=()=>{const{data:e}=this.props,t=e.categoryHierarchy.result;return{CategoryHierarchyContainer:{tag:"nav",className:"ms-search-result-container__category-hierarchy"},categoryHierarchyList:t&&t.map((e,t)=>h.createElement(T,{key:t,text:e.Name,ariaLabel:`${this.props.resources.categoryLinkAriaLabel} ${e.Name}`,href:e.Url})),categoryHierarchySeparator:h.createElement(S,{separator:"/"})}},this._getSortingDropDown=()=>{const{resources:e}=this.props,t=this._getCurrentlySelectedOption()||this.state.sortingState.selectedSortByOption;return{SortingContainer:{className:"ms-search-result-container__Sort-by-category"},sortByDropDown:h.createElement(i.LabeledDropdown,{labelClassname:"reviews-list-sort-by",labelText:e.sortByDropdownLabel,dropdownId:"categorySortByDropdown",dropdownClassname:"reviews-list-dropdown",toggleColor:"link",dropdownOptions:this.sortByDropdownOptions,selectedOption:t,onSelectOption:this._updateSortByDropdown,ref:this._sortAndFilterContainerRef})}},this._getPagination=()=>{const{config:e,context:t,data:r,resources:a}=this.props,s=r&&r.listPageState&&r.listPageState.result,n=Object(f.b)(t.request),o=e.itemsPerPage||10,l=s&&null!==s.currentPageNumber?s.currentPageNumber*(this.props.config.itemsPerPage||10):this.props.context.request.query&&+this.props.context.request.query.skip||0,c=s&&s.totalProductCount||0,d=a.flipperPrevious,u=a.flipperNext;return c<=o?null:h.createElement(i.UncontrolledPagination,{className:"ms-search-result-container__pagination",role:"navigation","aria-label":a.paginationAriaLabel,url:n.href,qsp:"skip",items:c,itemsPerPage:o,startingItem:l,previousText:h.createElement("div",{className:"msc-pagination__prev"},h.createElement("span",{className:"ms-search-result__pagination-left","aria-hidden":"true"}),h.createElement("span",{className:"prev-text"},d)),nextText:h.createElement("div",{className:"msc-pagination__next"},h.createElement("span",{className:"next-text"},u),h.createElement("span",{className:"ms-search-result__pagination-right","aria-hidden":"true"})),previousAriaLabel:d,nextAriaLabel:u,telemetryContent:this.telemetryContent})},this._getRefineMenu=()=>{const{data:e,context:t,config:r}=this.props,a=t.request.query&&t.request.query.inputRange?"input":"slider",s=e.refiners.result&&e.refiners.result.filter(e=>e.Values.length>0),n=e.listPageState.result&&e.listPageState.result.activeFilters||[];this._getexpandRefinerCount(s&&s.length,r.expandRefinersCount);const i=this.expandrefinerCount;return{RefineMenuContainer:{className:"ms-search-result-container__refine-menu"},RefinerSectionContainer:{className:"ms-search-result-container__refiner-section"},refiners:s&&s.map((e,r)=>h.createElement(G,{productRefinerHierarchy:e,selectedRefinerValues:n,refineItemCommonProps:this._refineItemCommonProps,minValueSliderThumbAriaLabel:this.props.resources.minValueSliderThumbAriaLabel,maxValueSliderThumbAriaLabel:this.props.resources.maxValueSliderThumbAriaLabel,key:r,onUpdateRefiners:this._onUpdateRefiners,urlBuilder:this._buildRefinerUrl,isDisabled:!1,isExpandedOnInitialLoad:!!(i&&i>r),tempRangeTypeTODO:a,context:t,moduleId:this.props.id,moduleTypeName:this.props.typeName,telemetryContent:this.telemetryContent}))}},this._getChoiceSummary=()=>{const{resources:e,data:t,telemetry:r}=this.props,a=t.listPageState.result&&t.listPageState.result.activeFilters||[];return h.createElement(F,{classNames:"ms-choice-summary-by-category",clearAllText:e.clearAllText,label:e.choiceSummaryLabel,selectedChoices:a,refinerHierarchy:t.refiners.result,choiceFormat:e.choiceFormat,choiceRangeValueFormat:e.choiceRangeValueFormat,telemetry:r,onChoiceClicked:this._onChoiceClicked,urlBuilder:this._buildRefinerUrlForChoiceSummary,choiceAriaLabel:e.choiceAriaLabel,telemetryContent:this.telemetryContent})},this._updateSortByDropdown=e=>{const{context:t}=this.props,r=t&&t.request,a=t&&t.actionContext;if(!r||!a||!this.props.data.listPageState.result){const e=`[sort-by-category] cannot sort without context: ${r?"":"requestContext "} ${a?"":"actionContext "} could not be found`;this.props.telemetry.warning(e)}window.history.pushState({},"",Object(f.a)(Object(f.b)(this.props.context.request),void 0,[this._getSortColumnFromSelectedOption(e.selectedOption)],void 0)),Object(m.s)(()=>{this.props.data.listPageState.result.currentPageNumber=0,this.props.data.listPageState.result.sortingCritera={Columns:[this._getSortColumnFromSelectedOption(e.selectedOption)]}})},this._getSortColumnFromSelectedOption=e=>{const{data:t}=this.props;if(!t.searchConfiguration.result)return{};const r=t.searchConfiguration.result.find(t=>t.key===e.key);return r?r.sortColumn:{}},this._getCurrentlySelectedOption=()=>{const{data:e}=this.props,t=e.listPageState.result&&e.listPageState.result.sortingCritera,r=t&&t.Columns&&t.Columns[0]||(Object(f.d)("sorting",this.props.context.request)||[])[0];if(r&&e.searchConfiguration.result){const t=e.searchConfiguration.result.find(e=>e.sortColumn.ColumnName===r.ColumnName&&e.sortColumn.IsDescending===r.IsDescending);if(t)return this.sortByDropdownOptions.find(e=>e.key===t.key)}},this._onUpdateRefiners=e=>{const{context:t}=this.props,r=t&&t.request,a=t&&t.actionContext;if(!r||!a||!this.props.data.listPageState.result){const e=`Refine menu cannot refine search criteria: ${r?"":"requestContext "} ${a?"":"actionContext "} could not be found`;this.props.telemetry.warning(e)}const s=w(e,this.props.data.listPageState.result&&this.props.data.listPageState.result.activeFilters||[]);window.history.pushState({},"",Object(f.a)(Object(f.b)(this.props.context.request),s)),Object(m.s)(()=>{this.props.data.listPageState.result.currentPageNumber=0,this.props.data.listPageState.result.activeFilters=s})},this._buildRefinerUrl=e=>{if(this.props.data.listPageState.result){const t=w(e,this.props.data.listPageState.result.activeFilters||[]);return Object(f.a)(Object(f.b)(this.props.context.request),t)}return this.props.telemetry.warning("[buildRefinerQueryString]List Page State Not available, unable to build refiner URL"),""},this._onChoiceClicked=e=>{const{data:t,telemetry:r}=this.props;if(!t.listPageState.result)return void r.warning("[choice-summary-by-category._onChoiceClicked]ListPageState unavailable, unable to update refiners.");let a=t.listPageState.result&&t.listPageState.result.activeFilters||[];if(e.clearAll){a=[];const e=this._sortAndFilterContainerRef.current&&this._sortAndFilterContainerRef.current.props.dropdownId,t=e&&document.getElementById(e);setTimeout(()=>{t&&t.focus()},50)}else{const t=e.choiceClicked;if(!t)return void r.warning("[choice-summary-by-category._onChoiceClicked] Choice could not be determined");a=a.filter(e=>!D(t,e))}const s=Object(f.b)(this.props.context.request);window.history.pushState({},"",Object(f.a)(s,a)),t.listPageState.result.currentPageNumber=0,t.listPageState.result.activeFilters=a},this._buildRefinerUrlForChoiceSummary=(e,t)=>{const{data:r,telemetry:a}=this.props,s=Object(f.b)(this.props.context.request);if(!r.listPageState.result)return a.warning("[choice-summary-by-category._buildRefinerUrl]ListPageState unavailable, unable to create refiner URL."),s.href;let n=r.listPageState.result&&r.listPageState.result.activeFilters||[];if(t)n=[];else{if(!e)return a.warning("[choice-summary-by-category._buildRefinerUrl] URL for Choice could not be determined"),s.href;n=n.filter(t=>!D(e,t))}return Object(f.a)(s,n)},this._getexpandRefinerCount=(e,t)=>{switch(t){case"all":this.expandrefinerCount=e;break;case"one":this.expandrefinerCount=1;break;case"two":this.expandrefinerCount=2;break;case"three":this.expandrefinerCount=3;break;case"four":this.expandrefinerCount=4;break;default:this.expandrefinerCount=0}},this._viewport=e.context.request&&e.context.request.device&&"Mobile"===e.context.request.device.Type?"xs":"lg",this._modalToggleRef=h.createRef(),this._sortAndFilterContainerRef=h.createRef(),this._toggleModal=this._toggleModal.bind(this),this._updateViewport=this._updateViewport.bind(this),this.productPrices=[],this.state={sortingState:{pending:!1,selectedSortByOption:this.sortByDropdownOptions[0]},modalIsOpen:!1};const{placeholderTextMax:a,minLabel:s,maxLabel:o,rangeNameFormat:d}=this.props.resources,u=this.props.context.request.locale,p=this.props.telemetry,_=this.props.resources.validationErrorNotNumber,C=this.props.resources.validationErrorNotRange;this._refineItemCommonProps={telemetry:p,locale:u,placeholderTextMax:a,minLabel:s,maxLabel:o,rangeNameFormat:d,validationErrorNaN:_,validationErrorRange:C},this.telemetryContent=Object(i.getTelemetryObject)(this.props.context.request.telemetryPageName,this.props.friendlyName,this.props.telemetry),this.props.data.products.then(e=>{this.props.data.listPageState.then(t=>{"Category"===this._pageType?t.pageType="Category":t.pageType="Search";let r=[];this.props.context.request.query&&this.props.context.request.query.sorting&&(r=JSON.parse(decodeURIComponent(this.props.context.request.query.sorting))),t.currentPageNumber=this.props.context.request.query&&+this.props.context.request.query.skip/(this.props.config.itemsPerPage||10)||0,t.sortingCritera={Columns:r},t.pageSize=this.props.config.itemsPerPage||10,t.activeProducts=e.products,t.totalProductCount=e.count,Object(m.o)(()=>[t.activeFilters&&t.activeFilters.length,t.currentPageNumber,t.sortingCritera&&t.sortingCritera.Columns&&t.sortingCritera.Columns.length],()=>{var e;const r=new y.GetFullProductsByCollectionInput(t.pageType,this.props.context.request.apiSettings,{Paging:{Top:this.props.config.itemsPerPage,Skip:Math.max(t.pageSize*(t.currentPageNumber||0),0)},count:!0,Sorting:t.sortingCritera||{}},t.activeFilters||[],+(this.props.context.request.urlTokens.itemId||0),this.props.context.request.query&&this.props.context.request.query.q?this.props.context.request.query.q:null===(e=this.props.context.request.query)||void 0===e?void 0:e.productId,!(!this.props||!this.props.config||void 0===this.props.config.includeAttributes||!0!==this.props.config.includeAttributes),this.props.context.request.locale);Object(y.default)(r,this.props.context.actionContext).then(e=>{var r,a;t.activeProducts=e.products,t.totalProductCount=e.count,this.props.config.enableAffiliationBasedPricing&&null!==(r=this.props.context.actionContext.requestContext)&&void 0!==r&&null!==(a=r.user)&&void 0!==a&&a.isAuthenticated&&this._getActivePrice()})})})}),null!==(r=this.props.context.request.query)&&void 0!==r&&r.productId&&this.props.data.featureProduct.then(e=>{this.props.data.listPageState.then(t=>{t.featureProduct=e})}),this._updateViewport()}get isMobile(){return"xs"===this._viewport||"sm"===this._viewport}static getFriendlyName(e,t){let r;return e&&t&&t.length>0&&(r=t.find(t=>t.Language.toLowerCase()===e.toLowerCase())),r&&r.Text}componentDidMount(){var e,t;o.default.isBrowser&&window.addEventListener&&(window.addEventListener("resize",this._updateViewport),this._updateViewport()),this.props.config.enableAffiliationBasedPricing&&null!==(e=this.props.context.actionContext.requestContext)&&void 0!==e&&null!==(t=e.user)&&void 0!==t&&t.isAuthenticated&&this._getActivePrice()}componentWillUnmount(){o.default.isBrowser&&window.removeEventListener&&window.removeEventListener("resize",this._updateViewport)}render(){const{imageSettings:e,className:t,allowBackNavigation:r}=this.props.config,{resources:a}=this.props,s=this.props.data.listPageState.result&&this.props.data.listPageState.result.activeProducts||[],n=this.props.data.listPageState.result&&this.props.data.listPageState.result.featureProduct||null;let i="";const o=this.props.context.app.config.breadcrumbType,l=r&&("back"===o||"categoryAndBack"===o);s&&0!==s.length||(i="Category"===this._pageType?a.resultCategoryNotFoundText:a.resultSearchNotFoundText);const c=h.createElement(C,{products:s,context:this.props.context,imageSettings:e,resources:a,moduleType:this.props.typeName,moduleId:this.props.id,allowBackNavigation:l,telemetryContent:this.telemetryContent}),d=h.createElement(v,{product:n,context:this.props.context,imageSettings:e,resources:a,moduleType:this.props.typeName,moduleId:this.props.id,telemetryContent:this.telemetryContent}),m=K(K({},this.props),{},{products:c,TitleViewProps:this._getCollectionTitle(),categoryHierarchy:!this.props.config.disableHierarchy&&this._getCategoryHierarchy(),refineMenu:this._getRefineMenu(),className:u()("ms-search-result-container",t),SearchResultContainer:{moduleProps:this.props,className:u()("ms-search-result-container",t)},sortByOptions:this.props.data.listPageState.result&&0!==this.props.data.listPageState.result.totalProductCount?this._getSortingDropDown():null,pagination:this._getPagination(),ProductsContainer:{className:"ms-search-result-container__Products"},ProductSectionContainer:{className:"ms-search-result-container__product-section"},CategoryNavContainer:{className:"ms-search-result-container__category-nav-section"},RefineAndProductSectionContainer:{className:"ms-search-result-container__refine-product-section"},choiceSummary:this._getChoiceSummary(),modalToggle:this.props.data.listPageState.result&&0!==this.props.data.listPageState.result.totalProductCount?h.createElement(q,{text:a.modalTitle,ariaLabel:a.modalTitle,innerRef:this._modalToggleRef,onClick:this._toggleModal,id:"search-result-modal"}):null,searchResultModal:this._getSearchResultModal(),isMobile:this.isMobile,errorMessage:i&&h.createElement($,{text:i}),FeatureSearchContainer:{className:"ms-feature-search-result"},similarLookProduct:this.props.data.listPageState.result&&null!==this.props.data.listPageState.result.featureProduct&&void 0!==this.props.data.listPageState.result.featureProduct?d:null,productPrices:this.productPrices});return this.props.renderView(m)}_getViewport(){const{context:e}=this.props;if(e.request&&e.request.device&&"Mobile"===e.request.device.Type)return"xs";if(o.default.isBrowser&&window.innerWidth){const t=e.request.gridSettings;if(t)return t.xs&&window.innerWidth<=t.xs.w?"xs":t.sm&&window.innerWidth<=t.sm.w?"sm":t.md&&window.innerWidth<=t.md.w?"md":t.lg&&window.innerWidth<=t.lg.w?"lg":"xl"}return"lg"}_toggleModal(){this.setState({modalIsOpen:!this.state.modalIsOpen})}_updateViewport(){this._viewport=this._getViewport(),this.state.modalIsOpen&&!this.isMobile&&this._toggleModal()}};Object(s.__decorate)([m.e],X.prototype,"isMobile",null),Object(s.__decorate)([m.n],X.prototype,"_viewport",void 0),X=Y=Object(s.__decorate)([p.a],X);t.default=X},IRZC:function(e,t,r){"use strict";r.d(t,"a",(function(){return m}));r("9VTn");var a=r("rePB"),s=(r("oLpx"),r("hBpL")),n=r("cDcd");function i(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,a)}return r}function o(e){for(var t=1;t{let{price:t,label:r,context:a,id:i,typeName:o,toBeCalculatedText:l,freeText:c,cssLabel:d}=e;return n.createElement("p",{className:"msc-order-summary__line-"+d},n.createElement("span",{className:"msc-order-summary__label"},r),t||0===t?n.createElement(s.k,{data:{price:{CustomerContextualPrice:t}},freePriceText:c,context:a,id:i,typeName:o,className:"msc-order-summary__value"}):n.createElement("span",{className:"msc-order-summary__value"},l))},c=function(e,t,r){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";return n.createElement(l,{price:t,label:a,context:e.context,id:e.id,typeName:e.typeName,toBeCalculatedText:e.toBeCalculatedText,freeText:e.freeText,telemetry:e.telemetry,cssLabel:r})},d=e=>e&&e.loyaltyAmount||0,u=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2?arguments[2]:void 0,a=arguments.length>3?arguments[3]:void 0;var s;return t?null==r||null===(s=r.PickupDeliveryModeCodes)||void 0===s?void 0:s.find(t=>t===e):a},m=e=>{const{SubtotalAmount:t,TaxAmount:r,DiscountAmountWithoutTax:a=0,TotalAmount:s,OtherChargeAmount:n}=e.cart,{canShip:i,hasDeliveryMethod:l,hasShippingMethod:m,freightFee:p}=((e,t,r,a)=>{const s=t&&t.PickupDeliveryModeCode,n=t&&t.EmailDeliveryModeCode,i=(e.CartLines||[]).map(e=>e.DeliveryMode),o=e.ShippingChargeAmount;return{canShip:i.some(e=>""===e||e!==u(e,a,r,s)&&e!==n),hasDeliveryMethod:i.some(e=>!!e&&e!==n),hasShippingMethod:i.some(e=>!!e&&e!==u(e,a,r,s)&&e!==n),freightFee:o}})(e.cart,e.channelConfiguration,e.channelDeliveryOptionConfig,e.retailMultiplePickUpOptionEnabled),h={subtotal:c(e,t,"sub-total",e.subTotalLabel),tax:c(e,l?r:void 0,"tax-amount",e.taxLabel),orderTotal:c(e,s,"total",e.orderTotalLabel),otherCharge:n&&c(e,n,"other-charges",e.otherChargeLabel)||void 0};if(i&&(h.shipping=c(e,m?p:void 0,"shipping",e.shippingLabel)),e.checkoutState){const t=((e,t)=>{const r=(e.giftCardExtends||[]).reduce((e,t)=>e+(t.Balance||0),0),a=(t.TotalAmount||0)-d(e);return Math.min(r,a)})(e.checkoutState,e.cart),r=d(e.checkoutState),a=(s||0)-t-r;r>0&&(h.loyalty=c(e,-r,"loyalty",e.loyaltyLabel||"Loyalty amount")),t>0&&(h.giftCard=c(e,-t,"gift-card",e.giftcardLabel||"Gift card amount")),h.orderTotal=c(o(o({},e),{},{freeText:void 0}),a,"total",e.orderTotalLabel)}return a>0&&(h.totalDiscounts=c(e,-a,"total-discounts",e.totalDiscountsLabel)),h}},ISoG:function(e,t,r){"use strict";r.r(t);r("WVYb"),r("y/s1"),r("LR6M"),r("ES/9"),r("Mqeb"),r("Yw3D"),r("m67q");var a=r("UdvX"),s=r("Hxoz"),n=r("hBpL"),i=r("xT9B"),o=r("u8oO"),l=r("57kZ"),c=r("Y2vv"),d=r("cDcd"),u=r.n(d),m=r("9ONQ"),p=r("ZOwJ");const h=new m.a;function g(e,t,r,a){return`${e=e||""} ${t=t||""} ${b(r,a)}`}function y(e){return u.a.createElement("p",{className:"msc-product__text"},e)}function b(e,t){if(e&&t){const r=e.toFixed(2);return Object(s.format)(t||"",r,"5")}return""}function f(e,t,r,a,s,i,o,l,c){const d={BasePrice:a,AdjustedPrice:s,CustomerContextualPrice:s};return u.a.createElement(n.k,{context:e,id:r,typeName:t,data:{price:d},savingsText:i,freePriceText:o,originalPriceText:l})}function T(e,t,r,a){if(!r||!t||!e)return null;const s={src:r,altText:a||""},n={gridSettings:t,imageSettings:e};return n.imageSettings.cropFocalRegion=!0,u.a.createElement(i.Image,Object.assign({},s,n,{loadFailureBehavior:"empty"}))}t.default=e=>{let{data:t,context:r,imageSettings:i,savingsText:d,freePriceText:m,originalPriceText:_,currentPriceText:C,ratingAriaLabel:v,allowBack:x,typeName:S,id:O,telemetryContent:P}=e;const N=t.product;if(!N)return null;let E=Object(a.getProductPageUrlSync)(N.Name||"",N.RecordId,r&&r.actionContext,void 0);x&&(E=function(e,t){const r=new URL(e,t.request.apiSettings.baseUrl);r.search?r.search+="&back=true":r.search+="back=true";return new URL(r.href).pathname+r.search}(E,r));const L=Object(s.getPayloadObject)("click",P,"",N.RecordId.toString()),I=Object(s.getTelemetryAttributes)(P,L),[D,w]=u.a.useState(!1),k={context:r,className:"msc-add-to-pmcart",id:O,typeName:S,data:{product:N,price:N.Price},dialogStrings:{},imageSettings:i,gridSettings:r.request.gridSettings,productQuantity:1,navigationUrl:"",modalOpen:D,setModalOpen:w},A=u.a.createElement(p.Popup,Object.assign({},k)),B=void 0!==r.request.urlTokens.categories?r.request.urlTokens.categories[0]:"",[M,R]=u.a.useState(!0);if(u.a.useEffect(()=>{(async()=>{var e;const t=await Object(c.j)(r&&r.actionContext,{ProductIds:[N.RecordId],DefaultWarehouseOnly:!0});t&&t&&t.ProductWarehouseInventoryAvailabilities&&(null===(e=t.ProductWarehouseInventoryAvailabilities)||void 0===e?void 0:e.length)>0?"Digital Gift Card"!==N.Name&&"OOS"===t.ProductWarehouseInventoryAvailabilities[0].PhysicalAvailableInventoryLevelCode?R(!1):R(!0):R(!1)})()},[]),"pick-mix"===B){const e=r.pmProducts,t=N.RecordId,a=e[t]&&e[t].Qty,[s,n]=u.a.useState(!(a>0&&void 0!==a)),[o,l]=u.a.useState(a>0&&void 0!==a?a:0),c=(h.set("pm_products",JSON.stringify(e),{path:"/"}),()=>{void 0===(void 0===h.get("pm_products")?{}:h.get("pm_products"))[N.RecordId]&&(l(0),n(!0))});u.a.useEffect(()=>{const e=document.getElementsByClassName("pm-cart--ctn")[0];function t(e){if(!("BUTTON"===e.target.nodeName))return;const t=setTimeout(()=>{c()},100);return()=>{clearTimeout(t)}}return e.addEventListener("click",t),()=>e.removeEventListener("click",t)});const p=e=>{let{showadd:t}=e;return t?u.a.createElement(u.a.Fragment,null,u.a.createElement("button",{className:"border-button add-to-mix-cart",onClick:()=>function(e,t,a,s,i,o){const c=r.pmProducts;n(!1),c[e]={Id:e,Item:t,Qty:i,UOM:"",Price:o,Description:"",DataAreaId:"",PrimaryImageUrl:s},r.pmProducts=c,l(1)}(N.RecordId,N.Name,N.Description,N.PrimaryImageUrl,1,N.Price)},"ADD")):u.a.createElement(u.a.Fragment,null,u.a.createElement("button",{onClick:()=>function(e){var t;const a=r.pmProducts,s=Number(null===(t=a[e])||void 0===t?void 0:t.Qty)-1;s>=0&&(a[e].Qty=s,l(s)),0===s&&(delete a[e],n(!0))}(N.RecordId),title:"Press to decrease the quantity by 1",className:"decrement quantity__controls","aria-hidden":"true","aria-label":"Press to decrease the quantity by 1",color:"secondary"}),u.a.createElement("input",{type:"number",className:"quantity-input",pattern:"[0-9]*",value:o,"aria-live":"polite","aria-label":"quantity input",role:"spinbutton","aria-valuemin":0,"aria-valuemax":1e3,"aria-valuenow":0}),u.a.createElement("button",{onClick:()=>function(e){var t;const a=r.pmProducts,s=Number(null===(t=a[e])||void 0===t?void 0:t.Qty)+1;void 0!==a[e]&&(a[e].Qty=s,l(s))}(N.RecordId),title:"Press to increment quantity by 1",className:"increment quantity__controls ","aria-hidden":"true","aria-label":"Press to increment quantity by 1",color:"secondary"}))};return u.a.createElement("div",{className:"msc-product__mix-item"},u.a.createElement("div",{className:"msc-product__image"},T(i,r.request.gridSettings,N.PrimaryImageUrl,N.Name)),u.a.createElement("div",{className:"msc-product__details"},u.a.createElement("h4",{className:"msc-product__title"},N.Name),A,u.a.createElement("a",Object.assign({onClick:()=>w(!0),"aria-label":g(N.Name,r.cultureFormatter.formatCurrency(N.Price),N.AverageRating,v),className:"hyperlink view_details "},I),"View details"),y(N.Description),f(r,S,O,N.BasePrice,N.Price,d,m,_,C),u.a.createElement("div",{className:"quantity"},u.a.createElement(p,{showadd:s}))))}{const e=async()=>{const e=await Object(o.a)(null==r?void 0:r.actionContext),t=[{ItemId:N.ItemId,ProductId:N.RecordId,Quantity:1,TrackingId:""}];return Object(l.a)({callerContext:r.actionContext},e.cart.Id,t,e.cart.Version).then(async t=>{await e.refreshCart({})})};return u.a.createElement(u.a.Fragment,null,u.a.createElement("a",Object.assign({href:E,onClick:Object(s.onTelemetryClick)(P,L,N.Name),"aria-label":g(N.Name,r.cultureFormatter.formatCurrency(N.Price),N.AverageRating,v),className:"msc-product status_"+(M?"AVAL":"OOS")},I),u.a.createElement("div",{className:"msc-product__image"},T(i,r.request.gridSettings,N.PrimaryImageUrl,N.Name)),u.a.createElement("div",{className:"msc-product__details"},u.a.createElement("h4",{className:"msc-product__title"},N.Name),M?u.a.createElement("div",null):u.a.createElement("div",{className:"ms-buybox__inventory-info"},u.a.createElement("span",{className:"ms-buybox__inventory-label ms-buybox__inventory-code-oos"},"OUT OF STOCK")),f(r,S,O,N.BasePrice,N.Price,d,m,_,C),y(N.Description),!r.app.config.hideRating&&function(e,t,r,a,s,i){if(!a)return null;const o=s&&s.toString()||void 0,l=b(a,i);return u.a.createElement(n.n,{context:e,id:r,typeName:t,avgRating:a,ratingCount:o,readOnly:!0,ariaLabel:l,data:{}})}(r,S,O,N.AverageRating,N.TotalRatings,v))),M?u.a.createElement("button",{className:"solid-button msc-add-to-cart",onClick:e}):"")}}},KQxK:function(e,t,r){"use strict";r("BDvt"),r("WVYb");var a=r("UdvX"),s=r("Hxoz"),n=r("xT9B"),i=r("cDcd");t.a=e=>{var t,r,o,l;const{dialogStrings:c,className:d,imageSettings:u,gridSettings:m,data:{product:p},productQuantity:h,modalOpen:g,setModalOpen:y,context:b}=e;if(!c||!p)return null;const f=()=>{y(!1)},T=Object(a.getFallbackImageUrl)(p.ItemId,b.actionContext.requestContext.apiSettings),_=void 0!==h?h:1,C=1===_?c.headerItemOneText:c.headerItemFormatText.replace("{0}",_.toString()),v=["20Glutenfree","18Vegan","22Noaddedsugar"],x=["Gluten free","Vegan friendly","No sugars added"],S=["25Productdescription(webs","17Nutritionalvalues","15Ingredients"],O=["Description","Nutritional values","Ingredients"];return i.createElement(s.Modal,{isOpen:g,onClosed:f,className:d+"__dialog"},i.createElement(s.ModalHeader,{toggle:f,className:d+"__dialog__header"},i.createElement("span",null,C),i.createElement("span",null,c.headerMessageText)),i.createElement("div",{className:"container"},i.createElement(s.ModalBody,{className:d+"__dialog__body row"},i.createElement("div",{className:"col-md-5"},i.createElement(n.Image,{className:d+"__dialog__image",src:p.PrimaryImageUrl||"",fallBackSrc:T,altText:p.Name,gridSettings:m||{},imageSettings:u,loadFailureBehavior:"empty"})),i.createElement("div",{className:d+"__dialog__product-info__ctn col-md-7"},i.createElement("h1",{className:d+"__dialog__product-title"},p.Name),i.createElement("div",{className:d+"__dialog__product-price"},b.cultureFormatter.formatCurrency(p.Price)," "),i.createElement("div",{className:"product-tags"},null===(t=p.AttributeValues)||void 0===t||null===(r=t.slice())||void 0===r?void 0:r.map((e,t)=>{if(e.KeyName&&v.includes(e.KeyName)&&"No"!==e.TextValue){const t=x[v.indexOf(e.KeyName)],r=t.replace(/\s+/g,"");return i.createElement(i.Fragment,null,i.createElement("span",{className:"tag tag_"+r},t))}})),i.createElement("div",{className:"specifications_rows"},null===(o=p.AttributeValues)||void 0===o||null===(l=o.slice())||void 0===l?void 0:l.map((e,t)=>{if(e.KeyName&&S.includes(e.KeyName)&&"No"!==e.TextValue){const t=O[S.indexOf(e.KeyName)],r=t.replace(/\s+/g,"");return i.createElement("div",{className:r},i.createElement("h4",null,t),i.createElement("div",{className:"content"},e.TextValue))}}))))))}},KnGS:function(e,t,r){"use strict";r.r(t);r("9VTn");var a=r("rePB"),s=(r("WVYb"),r("ES/9"),r("LR6M"),r("EawV"),r("mrSG")),n=r("IRZC"),i=r("UdvX"),o=r("Hxoz"),l=r("hBpL"),c=r("xT9B"),d=r("OtQ+"),u=r("57kZ"),m=r("TSYQ"),p=r.n(m),h=r("2vnA"),g=r("okNM"),y=r("cDcd"),b=r.n(y),f=(r("y/s1"),r("bt/X")),T=r.n(f);r("BDvt");const _=e=>{const t=t=>{const{storeSelectorStateManager:r,product:a,cartline:s,cartState:n,storeSelectorModuleId:i}=e;if(t){if(!r)return;r.openDialog({id:i,product:a,alreadySelectedLocation:{OrgUnitNumber:s.FulfillmentStoreId},deliveryOptions:e.deliveryOptions,onLocationSelected:(t,r)=>((t,r,a,s)=>r?r.updateCartLinePickupLocation({cartLineId:a.LineId,location:t,deliveryMode:s}).then(t=>{"SUCCESS"===t.status&&e.locationChangedHandler()}).catch(e=>{}):Promise.resolve())(t,n,s,r)}).catch(e=>{})}else{if(!n)return;s.DeliveryMode="",s.FulfillmentStoreId="",s.ShippingAddress={},n.clearCartLinePickupLocation({cartLineId:s.LineId}).then(t=>{"SUCCESS"===t.status&&e.locationChangedHandler()}).catch(e=>{})}},r=(e,t)=>{if(!(t&&e&&t.length>0))return"";const r=t.find(t=>t.OrgUnitNumber===e);return r?r.OrgUnitName:e};if(e.deliveryOptions&&e.deliveryOptions.DeliveryOptions&&e.pickupDeliveryModeCode&&e.deliveryOptions.DeliveryOptions.find(t=>t.Code===e.pickupDeliveryModeCode))return{callbacks:{toggleBopis:t},defaultComponent:((e,a,s,n,i)=>{const o=r(e.FulfillmentStoreId,i),l=!!e.FulfillmentStoreId,c=e=>()=>t(e);return y.createElement(y.Fragment,null,y.createElement("label",{className:"msc-cart-line__bopis-shipping"},y.createElement("input",{id:"ms-cart-bopis-ship-option-"+e.LineId,type:"radio",name:"shippingType "+e.LineId,onChange:c(!1),value:a,checked:!l,"aria-checked":!l,key:e.LineId+"-shipit"}),a),y.createElement("label",{className:"msc-cart-line__bopis-store-pickup"},y.createElement("input",{id:"ms-cart-bopis-pickup-option-"+e.LineId,type:"radio",name:"shippingType "+e.LineId,onChange:c(!0),value:s,checked:l,"aria-checked":l,key:e.LineId+"-pickup"}),s),e.FulfillmentStoreId?y.createElement("div",{className:"msc-cart-line__bopis__fullfilment"},y.createElement("span",{className:"msc-cart-line__bopis__fullfilment-store"},o),y.createElement("button",{className:"msc-cart-line__bopis-changestore btn",onClick:c(!0)},n)):null)})(e.cartline,e.shipitText,e.pickUpInStoreText,e.changeStoreText,e.orgUnitLocations),orgUnitName:r(e.cartline.FulfillmentStoreId,e.orgUnitLocations),isBopisSelected:!!e.cartline.FulfillmentStoreId,deliveryOption:((e,t)=>{var r;const a=null==t||null===(r=t.DeliveryOptions)||void 0===r?void 0:r.find(t=>t.Code===e.pickupDeliveryModeCode);return null==a?void 0:a.Description})(e,e.deliveryOptions),ContainerProps:{className:"msc-cart-line__bopis-container"}}},C=(e,t,r)=>{const a=[];return e.map((e,s)=>{const n=((e,t)=>{if(void 0!==e&&t)return t.find(t=>e===t.RecordId)})(e.ProductId,t);let d,u;r.productAvailabilites&&r.productAvailabilites.length>0&&(d=r.productAvailabilites.find(t=>{var r;return(null===(r=t.ProductAvailableQuantity)||void 0===r?void 0:r.ProductId)===e.ProductId&&t.InventLocationId===e.WarehouseId})),r.productDeliveryOptions&&r.productDeliveryOptions.length>0&&(u=r.productDeliveryOptions.find(t=>t&&t.ProductId===e.ProductId)),a.push(((e,t,r,a,s,n)=>{var d,u,m,p,h,g;const{imageSettings:b,gridSettings:f,id:T,typeName:C,context:v,resources:x,removeButtonText:S,removeItemClickHandler:O,moveToWishlistSuccessHandler:P,addToOrderTemplateButtonText:N,addToOrderTemplateDialogResources:E,createOrderTemplateDialogResources:L,itemAddedToOrderTemplateDialogResources:I,duplicateItemsWhenAddingToOrderTemplateDialogResources:D,addToWishlistButtonText:w,removeFromWishlistButtonText:k,orderTemplates:A,customerInformation:B,wishlists:M,defaultWishlistName:R,storeSelectorModuleId:j}=r,V=v.request.user.isAuthenticated,F=M&&M.length>0&&M[0].Name?M[0].Name:R,q=t&&((e,t,r,a)=>{const s=a||e;return t?r&&r.ProductAvailableQuantity&&r.IsProductAvailable&&r.ProductAvailableQuantity.AvailableQuantity?r.ProductAvailableQuantity.AvailableQuantity>=s?s:r.ProductAvailableQuantity.AvailableQuantity:0:s})(r.maxCartlineQuantity,r.isStockCheckEnabled,s,r.isQuantityLimitsFeatureEnabled?null===(d=t.Behavior)||void 0===d?void 0:d.MaximumQuantity:void 0),U=2===(null==t?void 0:t.ItemTypeValue),H=i.ObjectExtensions.isNullOrUndefined(q)?void 0:((e,t,r,a,s)=>{const n=[];if(r.includeErrors&&r.isStockCheckEnabled&&!s&&(e<=0?n.push(r.outOfStockText):ee.LineIndex===a).forEach(e=>{var t;null!==(t=e.DataValidationFailure)&&void 0!==t&&t.ErrorContext&&n.push(e.DataValidationFailure.ErrorContext)}),n.length>0)return n.join(" ")})(q,e.Quantity,r,a,U),Q=Object(o.getPayloadObject)(c.TelemetryEvent.RemoveFromCart,r.telemetryContent,S,""),W=Object(o.getTelemetryAttributes)(r.telemetryContent,Q),G=null==s?void 0:s.StockLevelLabel,$=s?"ms-cart-line__inventory-code-"+(null===(u=s.StockLevelCode)||void 0===u?void 0:u.toLowerCase()):void 0,z="Custom"===(null==t||null===(m=t.Dimensions)||void 0===m||null===(p=m.find(e=>4===e.DimensionTypeValue))||void 0===p||null===(h=p.DimensionValue)||void 0===h?void 0:h.Value);return{data:{product:t,cartline:e},error:H,cartline:y.createElement(l.g,{data:{cartLine:e,product:t},currentQuantity:e.Quantity,maxQuantity:q,isOutOfStock:!(U||!r.isStockCheckEnabled||!i.ObjectExtensions.isNullOrUndefined(q))&&q<=0,gridSettings:f,imageSettings:b,id:T,typeName:C,productUrl:t?Object(i.getProductUrlSync)(t,r.context.actionContext,void 0):void 0,context:v,resources:x,key:a,isQuantityEditable:!i.ObjectExtensions.isNullOrUndefined(t),quantityOnChange:r.updateCartLinesQuantitySuccessHandler,primaryImageUrl:null==t?void 0:t.PrimaryImageUrl,errorMessage:H,inventoryInformationLabel:G,inventoryLabelClassName:$,isCartStateReady:"READY"===(null===(g=r.cartState)||void 0===g?void 0:g.status),showShippingChargesForLineItems:r.showShippingChargesForLineItems,telemetryContent:r.telemetryContent,channelDeliveryOptionConfig:r.channelDeliveryOptionConfig}),pickUpInStore:t?_({storeSelectorModuleId:j,cartState:r.cartState,cartline:e,product:t,shipitText:r.shipItText,pickUpInStoreText:r.pickitUpText,changeStoreText:r.changeStoreText,storeSelectorStateManager:r.storeSelectorStateManager,orgUnitLocations:r.orgUnitLocations,deliveryOptions:n,pickupDeliveryModeCode:""!==e.DeliveryMode?e.DeliveryMode:r.pickupDeliveryModeCode,locationChangedHandler:r.locationChangedHandler}):void 0,remove:y.createElement(o.Button,Object.assign({className:"msc-cart-line__remove-item",onClick:t=>{O(e)},title:S},W),S),addToWishlist:V&&t&&!z?y.createElement(l.d,{className:"msc-cart-line__add-to-wishlist",addToWishlistButtonText:w,removeFromWishlistButtonText:k,context:v,id:T,key:e.LineId,typeName:C,nameOfWishlist:F,cartline:e,showButtonText:!0,showStatusMessage:!1,showRemoveButton:!1,showButtonTooltip:!1,data:{wishlists:M,product:t},onSuccess:P}):void 0,addToOrderTemplate:V&&A&&t&&!z?y.createElement(l.c,{className:"msc-cart-line__add-to-order-template",addToOrderTemplateButtonText:N,addToOrderTemplateDialogResources:E,createOrderTemplateDialogResources:L,itemAddedToOrderTemplateDialogResources:I,duplicateItemsWhenAddingToOrderTemplateDialogResources:D,data:{product:t,quantity:e.Quantity||1,orderTemplates:A,customerInformation:B},context:v,showButtonText:!0,showButtonTooltip:!1,id:T,typeName:C}):void 0}})(e,n,r,s,d,u))}),a},v=e=>{const{products:t,cartlines:r}=e;return((e,t,r)=>{const a=[];if(!t||0===t.length)return r.context.telemetry.error("Products content is empty, module wont render"),null;const s=e=>T()(e,e=>e.FulfillmentStoreId),n=(i=e,T()(i,e=>e.DeliveryMode));var i;const o=[];return Object.entries(n).forEach(e=>{let[t,r]=e;n[t]=s(r),o.push(s(r))}),Object.keys(o).forEach(e=>{const s=o[e];Object.keys(s).forEach(e=>{const n=s[e],i=C(n,t,r);null!==i&&a.push(i)})}),a})(r,t,e)};async function x(e){const t={};return await Object(i.getPromotionOptionsForCartLineItems)(new i.PromotionOptionsForCartLineItems(e.requestContext.apiSettings),e).then(e=>{e&&(t.promotionOptions=e)}).catch(t=>(e.telemetry.exception(t),{})),t}function S(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,a)}return r}function O(e){for(var t=1;t{this.setState({showPromotionDialog:!this.state.showPromotionDialog})},this.promotionCloseButtonclick=()=>{this._hidePromotionDialog()},this._getImageSettings=e=>e||{viewports:{xs:{q:"w=80&h=94&m=6",w:0,h:0},sm:{q:"w=148&h=174&m=6",w:0,h:0},lg:{q:"w=148&h=174&m=6",w:0,h:0}},lazyload:!0},this._removeItemFromCartHandler=e=>{if(this.props.data.cart.result){const t={cartLineIds:[e.LineId.toString()]};this.props.data.cart.result.removeCartLines(t).then(()=>{this._validateCart().catch(e=>{this.props.telemetry.warning(e),this.props.telemetry.debug("Unable to validate Cart")})}).catch(e=>{this.props.telemetry.warning(e),this.props.telemetry.debug("Unable to Remove Cart Line")})}},this._moveToWishlistSuccessHandler=(e,t)=>{"ADDED"===e.status&&t&&this._removeItemFromCartHandler(t)},this._updateCartlineQuantity=(e,t)=>{if(this.props.data.cart.result){const r={cartLineId:e.LineId.toString(),newQuantity:t,additionalProperties:{orderQuantityLimitsFeatureIsEnabled:this.isQuantityLimitsFeatureEnabled}};this.props.data.cart.result.updateCartLineQuantity(r).then(e=>"SUCCESS"===e.status&&(this._validateCart().catch(e=>{this.props.telemetry.warning(e),this.props.telemetry.debug("Unable to validate Cart")}),!0)).catch(e=>{this.props.telemetry.warning(e),this.props.telemetry.debug("Unable to update Cart Line quantity")})}return!1},this._fulfillmentStoreIdUpdated=()=>{this._validateCart().catch(e=>{this.props.telemetry.warning(e),this.props.telemetry.debug("Unable to validate Cart")})},this.telemetryContent=Object(o.getTelemetryObject)(this.props.context.request.telemetryPageName,this.props.friendlyName,this.props.telemetry),this.payLoad=Object(o.getPayloadObject)("click",this.telemetryContent,""),this.promotionLinkClick=this.promotionLinkClick.bind(this),this.promotionCloseButtonclick=this.promotionCloseButtonclick.bind(this)}async componentDidMount(){const{config:e,context:{actionContext:t}}=this.props;var r;(this.isQuantityLimitsFeatureEnabled=await this._getOrderQuantityLimitsFeatureFlag(),this.isQuantityLimitsFeatureEnabled&&await this._validateCart(),e.showAvailablePromotions)&&(null!==(r=this.props.data.cart.result)&&void 0!==r&&r.cart.CartLines&&this.setState({promotionData:await x(t)}),Object(h.o)(()=>{var e;return null===(e=this.props.data.cart.result)||void 0===e?void 0:e.cart.CartLines},async()=>{this.setState({promotionData:await x(t)})}))}render(){var e;const{data:{cart:{result:t},products:{result:r}},context:{request:{user:{isAuthenticated:a,signInUrl:s}}},resources:n}=this.props,d=Object(c.getUrlSync)("checkout",this.props.context.actionContext)||"",u=Object(c.getUrlSync)("home",this.props.context.actionContext)||"",m=this._getCheckoutURL(a,d,s||""),h=t&&t.cart.CartLines&&0===t.cart.CartLines.length,g=this._getCartLines(),y=null===(e=this.props.data.featureState.result)||void 0===e?void 0:e.find(e=>"Dynamics.AX.Application.RetailMultiplePickupDeliveryModeFeature"===e.Name),f=null!=y&&y.IsEnabled?this._getCartLinesGroup():null;this.payLoad.contentAction.etext=o.TelemetryConstant.Checkout;const T=Object(o.getTelemetryAttributes)(this.telemetryContent,this.payLoad);this.payLoad.contentAction.etext=o.TelemetryConstant.GuestCheckout;const _=Object(o.getTelemetryAttributes)(this.telemetryContent,this.payLoad);this.payLoad.contentAction.etext=o.TelemetryConstant.BackToShopping;const C=Object(o.getTelemetryAttributes)(this.telemetryContent,this.payLoad),v=!!g&&g.some(e=>void 0!==e.error),x=O(O({},this.props),{},{className:p()("ms-cart"),title:b.a.createElement("h1",{className:"msc-cart__heading"},n.cartTitle),CartlinesWrapper:{className:"msc-cartline-wraper"},OrderSummaryWrapper:{className:"msc-order-summary-wrapper"},OrderSummaryItems:{className:"msc-order-summary__items"},cartlines:g,cartLinesGroup:f,promoCode:this._getPromoCode(),promotionOptions:this._getPromotions(),cart:this.props.data.cart.result,context:this.props.context,typeName:this.props.typeName,telemetry:this.props.telemetry,id:this.props.id,mulitplePickUpEnabled:null==y?void 0:y.IsEnabled,removePromoAriaLabelFormat:n.removePromoAriaLabelFormat,orderSummaryHeading:i.ArrayExtensions.hasElements(null==t?void 0:t.cart.CartLines)?b.a.createElement("h2",{className:"msc-order-summary__heading"},n.orderSummaryTitle):null,orderSummaryLineitems:this._getOrderSummaryLineItems(),checkoutAsSignInUserButton:h?null:b.a.createElement(o.Button,Object.assign({disabled:v,className:"msc-cart__btn-checkout",href:m,title:n.checkoutButtonTitle},T),n.checkoutButtonTitle),checkoutAsGuestButton:h||a?null:b.a.createElement(o.Button,Object.assign({disabled:v,className:"msc-cart__btn-guestcheckout",href:d,title:n.guestCheckoutButtonTitle},_),n.guestCheckoutButtonTitle),backToShoppingButton:b.a.createElement(o.Button,Object.assign({className:"msc-cart__btn-backtoshopping"},C,{href:u,title:n.backToShoppingButtonTitle}),n.backToShoppingButtonTitle),createTemplateFromCartButton:this._displayAddCartToTemplate()&&r?b.a.createElement(l.p,{addToOrderTemplateDialogResources:this._generateAddToOrderTemplateDialogResources(n),createOrderTemplateDialogResources:this._generateOrderTemplateNameDialogResources(n),linesAddedToOrderTemplateDialogResources:this._generateLinesAddedToOrderTemplateDialogResources(n),createOrderTemplateFromCartButton:n.createOrderTemplateFromCartButton,context:this.props.context,id:this.props.id,typeName:this.props.typeName,data:{orderTemplates:this.props.data.orderTemplates.result,cartLines:this.props.data.cart.result.cart.CartLines,customerInformation:this.props.data.customerInformation.result}}):null,storeSelector:this.props.slots.storeSelector&&this.props.slots.storeSelector.length>0?this.props.slots.storeSelector[0]:null,removeItemClickHandler:this._removeItemFromCartHandler,moveToWishlistSuccessHandler:this._moveToWishlistSuccessHandler,waitingComponent:b.a.createElement(o.Waiting,{className:"msc-waiting-circular msc-waiting-lg"}),cartLoadingStatus:"FAILED"===this.props.data.cart.status?this.props.resources.cartLoadingErrorMessage:null,cartDataResult:this.props.data.cart.result&&this.props.data.cart.result.isEmpty,OrderSummaryErrors:this._getOrderSummaryErrors(g),telemetryContent:this.telemetryContent});return this.props.renderView(x)}_hidePromotionDialog(){this.setState({showPromotionDialog:!1})}_displayAddCartToTemplate(){var e,t,r,a,s;const n=null===(e=this.props.data.featureState.result)||void 0===e?void 0:e.find(e=>"Dynamics.AX.Application.RetailB2BEcommerceFeature"===e.Name);return!!(null!=n&&n.IsEnabled&&null!==(t=this.props.data.customerInformation.result)&&void 0!==t&&t.IsB2b&&this.props.data.orderTemplates.result&&null!==(r=this.props.data.cart.result)&&void 0!==r&&null!==(a=r.cart)&&void 0!==a&&null!==(s=a.CartLines)&&void 0!==s&&s.length&&this.props.data.cart.result.cart.CartLines.length>0&&this.props.data.customerInformation.result)}_getPromotions(){return this.props.config.showAvailablePromotions&&(e=>{const{id:t,showPromotionPopup:r,promotions:a,resources:{promotionLinkText:s,promotionPopupHeading:n},onCloseButtonClick:l,onSeeAllClick:c}=e;if(!i.ArrayExtensions.hasElements(a))return;const d=t+"_title",u="msc-cart__promotion";return{promotionMessageWrapper:{className:"msc-cart__promotion"},promotionMessage:b.a.createElement(b.a.Fragment,null,b.a.createElement("span",{className:"msi-promotion-icon"}),b.a.createElement("span",null," ",e.resources.promotionStringHeading)),promotionSeeAllLink:b.a.createElement("a",{className:"msc-cart__promotion_link",role:"link",onClick:c}," ",s," "),promotionDialog:b.a.createElement(o.Modal,{isOpen:r,className:""+u,toggle:l},b.a.createElement(o.ModalHeader,{className:u+"__dialog__header",toggle:l},b.a.createElement("h5",{id:d,className:"msc-cart__promotion-popup_title"},n)),b.a.createElement(o.ModalBody,{className:u+"__dialog__body"},b.a.createElement("ul",null,a.map(e=>{var t;return b.a.createElement("li",{className:"msc-cart__promotion-popup_name",key:e.LineId},null===(t=e.Promotion)||void 0===t?void 0:t.OfferName," ")}))),b.a.createElement(o.ModalFooter,{className:u+"__dialog__footer"}))}})({id:this.promotionPopupId,showPromotionPopup:this.state.showPromotionDialog,onSeeAllClick:this.promotionLinkClick,onCloseButtonClick:this.promotionCloseButtonclick,promotions:this.state.promotionData.promotionOptions,resources:{promotionStringHeading:this.props.resources.promotionStringHeading,promotionLinkText:this.props.resources.promotionLinkText,promotionPopupHeading:this.props.resources.promotionPopupHeading,promotionCloseButtonAriaLabel:this.props.resources.promotionCloseButtonAriaLabel}})}_getOrderSummaryErrors(e){const t=e&&e.map(e=>{var t,r;if(!(2===(null===(t=e.data)||void 0===t||null===(r=t.product)||void 0===r?void 0:r.ItemTypeValue))&&e.error){var a;const t=e.data&&null!==(a=e.data.product)&&void 0!==a&&a.Name?`${e.data.product.Name}: ${e.error}`:e.error;return b.a.createElement("div",{className:"msc-alert__line"},t)}return null}).filter(e=>!!e)||[];return{Wrapper:{tag:o.Alert,className:"msc-alert",isOpen:t.length>0,color:"danger",assertive:!0,"aria-label":this.props.resources.outOfStockErrorMessageHeader},header:b.a.createElement("div",{className:"msc-alert__header","aria-hidden":"true"},b.a.createElement("span",{className:"msi-exclamation-triangle"}),b.a.createElement("span",null,this.props.resources.outOfStockErrorMessageHeader)),errors:t}}_getOrderSummaryLineItems(){var e,t,r,a;const{data:{cart:{result:s},channelDeliveryOptionConfig:o},telemetry:l,resources:c}=this.props,d=this.props.context&&this.props.context.request&&this.props.context.request.channel,u=null===(e=this.props)||void 0===e||null===(t=e.data)||void 0===t?void 0:t.featureState,m=null==u||null===(r=u.result)||void 0===r||null===(a=r.find(e=>"Dynamics.AX.Application.RetailMultiplePickupDeliveryModeFeature"===e.Name))||void 0===a?void 0:a.IsEnabled;return d&&i.ArrayExtensions.hasElements(null==s?void 0:s.cart.CartLines)?Object(n.a)({cart:s.cart,subTotalLabel:c.itemsWithCountLabel,shippingLabel:c.estimatedShippingLabel,otherChargeLabel:c.otherCharges,taxLabel:c.estimatedTaxLabel,orderTotalLabel:c.orderTotal,totalDiscountsLabel:c.totalDiscountsLabel,context:this.props.context,typeName:this.props.typeName,id:this.props.id,toBeCalculatedText:c.yetToBeCalculatedText,freeText:c.priceFree,channelConfiguration:d,retailMultiplePickUpOptionEnabled:m,channelDeliveryOptionConfig:null==o?void 0:o.result,telemetry:l}):void 0}_getPromoCode(){const{data:{cart:{result:e}},resources:t}=this.props;return e&&b.a.createElement(l.m,{cart:e,promoCodeHeadingText:t.promoCodeHeadingText,promoPlaceholderText:t.promoPlaceholderText,promoCodeApplyButtonText:t.promoCodeApplyButtonText,appliedPromoCodeHeadingText:t.appliedPromoCodeHeadingText,collapseTimeOut:350,removePromoAriaLabelFormat:t.removePromoAriaLabelFormat,removePromoText:t.removePromoText,invalidPromoCodeErrorText:t.invalidPromoCodeErrorText,failedToAddPromoCodeErrorText:t.failedToAddPromoCodeErrorText,failedToRemovePromoCodeErrorText:t.failedToRemovePromoCodeErrorText,duplicatePromoCodeErrorText:t.duplicatePromotionErrorText,context:this.props.context,id:this.props.id,typeName:this.props.typeName,data:{},telemetryContent:this.telemetryContent})}_generateAddToOrderTemplateDialogResources(e){return{addToOrderTemplateHeader:e.addToOrderTemplateHeader,noOrderTemplatesMessage:e.noOrderTemplatesMessage,noOrderTemplatesDescription:e.noOrderTemplatesDescription,createAnOrderTemplateButtonText:e.createAnOrderTemplateButtonText,createNewOrderTemplateButtonText:e.createNewOrderTemplateButtonText,cancelOrderTemplateCreationButtonText:e.cancelOrderTemplateCreationButtonText,selectTemplatesText:e.selectTemplatesText,addToTemplateButtonText:e.addToTemplateButtonText,lineItemsText:e.lineItemsText}}_generateItemAddedToOrderTemplateDialogResources(e){return{viewOrderTemplateButtonText:e.viewOrderTemplateButtonText,continueShoppingButtonText:e.continueShoppingButtonText,itemAddedToOrderTemplateHeaderItemOneText:e.itemAddedToOrderTemplateHeaderItemOneText,itemAddedToOrderTemplateHeaderItemFormatText:e.itemAddedToOrderTemplateHeaderItemFormatText,itemAddedToOrderTemplateHeaderMessageText:e.itemAddedToOrderTemplateHeaderMessageText,freePriceText:e.freePriceText,originalPriceText:e.originalPriceText,currentPriceText:e.currentPriceText}}_generateLinesAddedToOrderTemplateDialogResources(e){return{viewOrderTemplateButtonText:e.viewOrderTemplateButtonText,continueShoppingButtonText:e.continueShoppingButtonText,linesAddedToOrderTemplateHeaderItemsOneText:e.linesAddedToOrderTemplateHeaderItemsOneText,linesAddedToOrderTemplateHeaderItemsFormatText:e.linesAddedToOrderTemplateHeaderItemsFormatText,linesAddedToOrderTemplateHeaderLinesOneText:e.linesAddedToOrderTemplateHeaderLinesOneText,linesAddedToOrderTemplateHeaderLinesFormatText:e.linesAddedToOrderTemplateHeaderLinesFormatText,linesAddedToOrderTemplateHeaderMessageText:e.linesAddedToOrderTemplateHeaderMessageText}}_generateDuplicateItemsWhenAddingToOrderTemplateDialogResources(e){return{duplicatedProductsHeader:e.duplicatedProductsHeader,duplicatedProductsDescription:e.duplicatedProductsDescription,updateQuantityButtonText:e.updateQuantityButtonText,cancelDuplicateItemsButtonText:e.cancelDuplicateItemsButtonText}}_generateOrderTemplateNameDialogResources(e){return{orderTemplateHeaderLabel:e.createOrderTemplateHeader,orderTemplateTitleLabel:e.orderTemplateTitle,orderTemplateNameAriaLabel:e.orderTemplateNameAriaLabel,orderTemplateDescription:e.createOrderTemplateDescription,defaultOrderTemplateName:e.defaultOrderTemplateName,orderTemplateButtonLabel:e.createOrderTemplateButtonText,orderTemplateCancelButtonLabel:e.cancelNewOrderTemplateCreationButtonText}}_getCartLines(){const{data:{cart:{result:e},wishlists:{result:t},orderTemplates:{result:r},customerInformation:{result:a}},context:{request:{channel:{PickupDeliveryModeCode:s}={PickupDeliveryModeCode:void 0}}},config:n,telemetry:o,resources:l,modules:c}=this.props,d=this._getImageSettings(n.imageSettings),u=this.state.cartlinesErrors;let m="";return c&&Object.keys(c).length>0&&c.storeSelector&&c.storeSelector.length>0&&(m=c.storeSelector[0].id),i.ArrayExtensions.hasElements(null==e?void 0:e.cart.CartLines)?(e=>{const{products:t,cartlines:r}=e;return C(r,t,e)})({cartlines:e.cart.CartLines,storeSelectorModuleId:m,cartlinesErrors:u,products:this.props.data.products.result,productAvailabilites:this.props.data.productAvailabilites.result,productDeliveryOptions:this.props.data.deliveryOptions.result,imageSettings:d,isStockCheckEnabled:this.props.context.app.config.enableStockCheck||!1,maxCartlineQuantity:this.props.context.app.config.maxQuantityForCartLineItem,gridSettings:this.props.context.request.gridSettings,context:this.props.context,typeName:this.props.typeName,id:this.props.id,resources:{sizeString:l.productDimensionTypeSize,colorString:l.productDimensionTypeColor,configString:l.productDimensionTypeConfiguration,styleString:l.productDimensionTypeStyle,amountString:l.productDimensionTypeAmount,quantityDisplayString:l.quantityDisplayText,inputQuantityAriaLabel:l.inputQuantityAriaLabel,decrementButtonAriaLabel:l.decrementButtonAriaLabel,incrementButtonAriaLabel:l.incrementButtonAriaLabel,discountStringText:l.discountStringText,originalPriceText:l.originalPriceText,currentPriceText:l.currentPriceText,shippingChargesText:l.shippingCharges},telemetry:o,addToWishlistButtonText:l.addToWishlistButtonText,removeFromWishlistButtonText:l.removeFromWishlistButtonText,removeButtonText:l.removeCartButtonText,shipItText:l.shipInsteadDisplayText,pickitUpText:l.pickItUpDisplayText,changeStoreText:l.changeStoreDisplayText,storeSelectorStateManager:this.props.data.storeSelectorStateManager.result,outOfStockText:l.outOfStockErrorMessage,outOfRangeOneText:l.errorMessageOutOfRangeOneLeft,outOfRangeFormatText:l.errorMessageOutOfRangeFormat,cartState:this.props.data.cart.result,orgUnitLocations:this.props.data.orgUnitLocations.result,removeItemClickHandler:this._removeItemFromCartHandler,moveToWishlistSuccessHandler:this._moveToWishlistSuccessHandler,updateCartLinesQuantitySuccessHandler:this._updateCartlineQuantity,locationChangedHandler:this._fulfillmentStoreIdUpdated,wishlists:t,defaultWishlistName:l.defaultWishlistName,pickupDeliveryModeCode:s,includeErrors:n.showOutOfStockErrors,showShippingChargesForLineItems:n.showShippingChargesForLineItems,telemetryContent:this.telemetryContent,isQuantityLimitsFeatureEnabled:this.isQuantityLimitsFeatureEnabled,addToOrderTemplateDialogResources:this._generateAddToOrderTemplateDialogResources(l),createOrderTemplateDialogResources:this._generateOrderTemplateNameDialogResources(l),itemAddedToOrderTemplateDialogResources:this._generateItemAddedToOrderTemplateDialogResources(l),duplicateItemsWhenAddingToOrderTemplateDialogResources:this._generateDuplicateItemsWhenAddingToOrderTemplateDialogResources(l),addToOrderTemplateButtonText:l.addToOrderTemplateButtonText,addToOrderTemplateMessage:l.addToOrderTemplateMessage,addItemToOrderTemplateError:l.addItemToOrderTemplateError,orderTemplates:r,customerInformation:a}):null}_getCheckoutURL(e,t,r){if(e)return t;const a=new RegExp("^(?:[a-z]+:)?//","i").test(t);let s=t;return c.default.isBrowser&&!a&&(s=`${window.location.origin}${t}`),`${r}${-1===r.indexOf("?")?"?":"&"}ru=${s}`}async _validateCart(){var e;let t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];if(!this.isQuantityLimitsFeatureEnabled)return d.AsyncResult.resolve();const{data:{cart:r}}=this.props;let a;try{a=await r}catch(o){return this.props.telemetry.warning(o),this.props.telemetry.debug("Unable to get cart"),d.AsyncResult.resolve()}const s=null===(e=a.cart)||void 0===e?void 0:e.Version;if(!s)return this.props.telemetry.warning("Cart version not found for Cart validation request."),d.AsyncResult.resolve();try{var n,i;const e=await Object(u.v)({callerContext:this.props.context.actionContext},null===(n=a)||void 0===n||null===(i=n.cart)||void 0===i?void 0:i.Id,s);return this.setState({cartlinesErrors:e.ValidationFailuresByCartLines||[]}),d.AsyncResult.resolve()}catch(o){if(t&&"Microsoft_Dynamics_Commerce_Runtime_InvalidCartVersion"===o.name){try{await a.refreshCart({})}catch(l){return this.props.telemetry.warning(l),this.props.telemetry.debug("Unable to refresh Cart"),d.AsyncResult.resolve()}try{return await this._validateCart(!1),d.AsyncResult.resolve()}catch(c){return this.props.telemetry.warning(c),this.props.telemetry.debug("Unable to validate Cart"),d.AsyncResult.resolve()}}return this.props.telemetry.warning(o),this.props.telemetry.debug("Unable to validate Cart"),d.AsyncResult.resolve()}}async _getOrderQuantityLimitsFeatureFlag(){var e,t,r,a;const s=null===(e=this.props.context)||void 0===e||null===(t=e.request)||void 0===t||null===(r=t.app)||void 0===r||null===(a=r.platform)||void 0===a?void 0:a.enableDefaultOrderQuantityLimits;if("none"===s)return!1;try{var n;const e=await this.props.data.featureState;if(!((null===(n=e.find(e=>"Dynamics.AX.Application.RetailDefaultOrderQuantityLimitsFeature"===e.Name))||void 0===n?void 0:n.IsEnabled)||!1))return!1}catch(i){return this.props.telemetry.warning(i),this.props.telemetry.debug("Unable to get feature states"),!1}if("all"===s)return!0;try{const e=await this.props.data.customerInformation;return!!e&&("b2b"===s&&e.IsB2b||"b2c"===s&&!e.IsB2b)}catch(i){return this.props.telemetry.warning(i),this.props.telemetry.debug("Unable to get customer info"),!1}}_getCartLinesGroup(){var e,t,r,a;const{data:{cart:{result:s},wishlists:{result:n},orderTemplates:{result:i},customerInformation:{result:o}},context:{request:{channel:{PickupDeliveryModeCode:l}={PickupDeliveryModeCode:void 0}}},config:c,telemetry:d,resources:u,modules:m}=this.props,p=this._getImageSettings(c.imageSettings),h=(null===(e=this.props.data.featureState.result)||void 0===e||null===(t=e.find(e=>"Dynamics.AX.Application.RetailDefaultOrderQuantityLimitsFeature"===e.Name))||void 0===t?void 0:t.IsEnabled)||!1,g=this.state.cartlinesErrors;let y="";return m&&Object.keys(m).length>0&&m.storeSelector&&m.storeSelector.length>0&&(y=m.storeSelector[0].id),this.props.data.products&&this.props.data.products.result&&s&&s.cart.CartLines&&s.cart.CartLines.length>0&&null!==(r=this.props.data.channelDeliveryOptionConfig)&&void 0!==r&&r.result?v({cartlines:s.cart.CartLines,storeSelectorModuleId:y,cartlinesErrors:g,products:this.props.data.products.result,productAvailabilites:this.props.data.productAvailabilites.result,productDeliveryOptions:this.props.data.deliveryOptions.result,imageSettings:p,isStockCheckEnabled:this.props.context.app.config.enableStockCheck||!1,maxCartlineQuantity:this.props.context.app.config.maxQuantityForCartLineItem,gridSettings:this.props.context.request.gridSettings,context:this.props.context,typeName:this.props.typeName,id:this.props.id,resources:{sizeString:u.productDimensionTypeSize,colorString:u.productDimensionTypeColor,configString:u.productDimensionTypeConfiguration,styleString:u.productDimensionTypeStyle,amountString:u.productDimensionTypeAmount,quantityDisplayString:u.quantityDisplayText,inputQuantityAriaLabel:u.inputQuantityAriaLabel,decrementButtonAriaLabel:u.decrementButtonAriaLabel,incrementButtonAriaLabel:u.incrementButtonAriaLabel,discountStringText:u.discountStringText,originalPriceText:u.originalPriceText,currentPriceText:u.currentPriceText,shippingChargesText:u.shippingCharges},telemetry:d,addToWishlistButtonText:u.addToWishlistButtonText,removeFromWishlistButtonText:u.removeFromWishlistButtonText,removeButtonText:u.removeCartButtonText,shipItText:u.shipInsteadDisplayText,pickitUpText:u.pickItUpDisplayText,changeStoreText:u.changeStoreDisplayText,storeSelectorStateManager:this.props.data.storeSelectorStateManager.result,outOfStockText:u.outOfStockErrorMessage,outOfRangeOneText:u.errorMessageOutOfRangeOneLeft,outOfRangeFormatText:u.errorMessageOutOfRangeFormat,cartState:this.props.data.cart.result,orgUnitLocations:this.props.data.orgUnitLocations.result,removeItemClickHandler:this._removeItemFromCartHandler,moveToWishlistSuccessHandler:this._moveToWishlistSuccessHandler,updateCartLinesQuantitySuccessHandler:this._updateCartlineQuantity,locationChangedHandler:this._fulfillmentStoreIdUpdated,wishlists:n,defaultWishlistName:u.defaultWishlistName,pickupDeliveryModeCode:l,includeErrors:c.showOutOfStockErrors,showShippingChargesForLineItems:c.showShippingChargesForLineItems,telemetryContent:this.telemetryContent,isQuantityLimitsFeatureEnabled:h,addToOrderTemplateDialogResources:this._generateAddToOrderTemplateDialogResources(u),createOrderTemplateDialogResources:this._generateOrderTemplateNameDialogResources(u),itemAddedToOrderTemplateDialogResources:this._generateItemAddedToOrderTemplateDialogResources(u),duplicateItemsWhenAddingToOrderTemplateDialogResources:this._generateDuplicateItemsWhenAddingToOrderTemplateDialogResources(u),addToOrderTemplateButtonText:u.addToOrderTemplateButtonText,addToOrderTemplateMessage:u.addToOrderTemplateMessage,addItemToOrderTemplateError:u.addItemToOrderTemplateError,orderTemplates:i,customerInformation:o,channelDeliveryOptionConfig:null===(a=this.props.data.channelDeliveryOptionConfig)||void 0===a?void 0:a.result}):null}};P=Object(s.__decorate)([g.a],P);t.default=P},Ma3q:function(e,t,r){"use strict";var a=r("sEfC"),s=r.n(a),n=(r("LR6M"),r("WVYb"),r("mrSG")),i=r("Hxoz"),o=r("okNM"),l=r("cDcd");let c=class extends l.PureComponent{constructor(e){super(e),this.inputRef=l.createRef(),this._validateMin=()=>{const e=void 0===this.props.min?1:this.props.min;isNaN(this.state.currentInput)||this.state.currentInput{this.props.onChange&&this.props.onChange(this.state.currentInput)}):this.props.onChange&&this.props.onChange(this.state.currentInput)},this.state={currentInput:e.currentCount||1,isUpdateing:!1},this._onIncrement=this._onIncrement.bind(this),this._onDecrement=this._onDecrement.bind(this),this._handleChange=this._handleChange.bind(this),this.payLoad=Object(i.getPayloadObject)("click",this.props.telemetryContent,"")}componentDidUpdate(e){this.props.disabled||this.state.currentInput===this.props.currentCount||e.currentCount===this.props.currentCount||this.setState({currentInput:this.props.currentCount||1}),this.props.disabled&&!this.state.isUpdateing&&this.setState({isUpdateing:!0}),!this.props.disabled&&this.state.isUpdateing&&this.setState({currentInput:this.props.currentCount||1,isUpdateing:!1})}render(){const{min:e,max:t}=this.props,r=this.props.decrementGlyphClass+" quantity__controls-glyph",a=this.props.incrementGlyphClass+" quantity__controls-glyph",s=this.state.currentInput<=(e||1)||this.props.isGiftCard,n=this.state.currentInput>=t||this.props.isGiftCard,o=this.state.currentInput;this.payLoad.contentAction.etext=i.TelemetryConstant.DecrementQuantity;const c=Object(i.getTelemetryAttributes)(this.props.telemetryContent,this.payLoad);this.payLoad.contentAction.etext=i.TelemetryConstant.IncrementQuantity;const d=Object(i.getTelemetryAttributes)(this.props.telemetryContent,this.payLoad);let u="";s?u="disabled":this.props.disabled&&(u="transition");let m="";return n?m="disabled":this.props.disabled&&(m="transition"),l.createElement(l.Fragment,null,l.createElement("div",{className:"quantity",id:this.props.id},l.createElement("button",Object.assign({disabled:this.props.disabled||s,title:s?"":this.props.decrementButtonAriaLabel,className:"decrement quantity__controls "+u,onClick:this._onDecrement,"aria-hidden":!0,"aria-label":""+this.props.decrementButtonAriaLabel,tabIndex:-1,color:"secondary"},c),l.createElement("span",{className:r})),l.createElement("input",{type:"number",className:"quantity-input",pattern:"[0-9]*",value:this.state.currentInput,onChange:this._handleChange,onBlur:this._validateMin,"aria-live":"polite","aria-label":""+this.props.inputQuantityAriaLabel,role:"spinbutton","aria-valuemin":e,"aria-valuemax":t,"aria-valuenow":o,ref:this.inputRef,disabled:this.props.disabled}),l.createElement("button",Object.assign({disabled:this.props.disabled||n,title:n?"":this.props.incrementButtonAriaLabel,className:"increment quantity__controls "+m,onClick:this._onIncrement,"aria-hidden":!0,"aria-label":""+this.props.incrementButtonAriaLabel,tabIndex:-1,color:"secondary"},d),l.createElement("span",{className:a}))))}_onIncrement(){let e=!1;const t=this.state.currentInput;let r;t1?(e=!0,r=t-1):(e=!1,r=1),e&&this.props.onChange&&this.props.onChange(r)&&this.setState({currentInput:r})}_handleChange(e){const t=parseInt(e.target.value,10),r=void 0===this.props.min?1:this.props.min,a=this.inputRef&&this.inputRef.current&&this.inputRef.current instanceof HTMLInputElement&&this.inputRef.current;t>this.props.max?this.setState({currentInput:this.props.max},()=>{s()(()=>{this.props.onChange&&this.props.onChange(this.state.currentInput)},200)()}):this.setState({currentInput:t},()=>{s()(()=>{isNaN(this.state.currentInput)||this.state.currentInputthis.props.config.heading.text=e.target.value,this._getProduct=(e,t)=>{if(!e||!e.Name)return this.props.telemetry.trace("[product-collection] Product or product name is null"),null;const r=Object(n.getTelemetryObject)(this.props.context.request.telemetryPageName,this.props.friendlyName,this.props.telemetry),{imageSettings:a,allowBackNavigation:s}=this.props.config,o=this.props.resources,l=this.props.context.app.config.breadcrumbType,c=s&&("back"===l||"categoryAndBack"===l);return{ProductContainer:{tag:"li",className:"ms-product-collection__item",role:"listitem",key:t},productComponent:u.createElement(i.l,{context:this.props.context,telemetryContent:r,imageSettings:a,freePriceText:o.priceFree,originalPriceText:o.originalPriceText,currentPriceText:o.currentPriceText,ratingAriaLabel:o.ratingAriaLabel,allowBack:c,id:this.props.id,typeName:this.props.typeName,data:{product:e}})}},this._getActivePrice=async()=>{let e=this.state.products||[];const t=e&&e.length>0?e.map(e=>e.RecordId):[],r={ChannelId:this.props.context.request.apiSettings.channelId,CatalogId:this.props.context.request.apiSettings.catalogId},a=[],n=new s.GetCustomerInput(this.props.context.actionContext.requestContext.apiSettings),i=await Object(s.getCustomer)(n,this.props.context.actionContext);i&&i.CustomerAffiliations&&i.CustomerAffiliations.forEach(e=>{const t={AffiliationId:e.RetailAffiliationId,CustomerId:i.AccountNumber};a.push(t)}),await Object(l.c)({callerContext:this.props.context.actionContext,queryResultSettings:{}},r,t,new Date,null,a,!0).then(t=>{this.productPrices=t,e=e.map(e=>{const r=t.find(t=>t.ProductId===e.RecordId);var a;r&&(e.Price=null!==(a=r.CustomerContextualPrice)&&void 0!==a?a:e.Price,e.BasePrice=Math.max(r.BasePrice||0,r.TradeAgreementPrice||0,r.AdjustedPrice||0));return e}),this.setState({products:e})}).catch(e=>{throw this.props.context.actionContext.trace(e.message),this.props.context.actionContext.telemetry.exception(e),this.props.context.actionContext.telemetry.debug("[get Affiliation based price on Product Collection]Error executing action"),new Error("[get Affiliation based price on Product Collection]Error executing action")})},this.productPrices=[],this.state={products:this.props.config.productCollection&&this.props.config.productCollection.products},this.telemetryContent=Object(n.getTelemetryObject)(this.props.context.request.telemetryPageName,this.props.friendlyName,this.props.telemetry)}componentDidMount(){var e,t;this.props.config.enableAffiliationBasedPricing&&null!==(e=this.props.context.actionContext.requestContext)&&void 0!==e&&null!==(t=e.user)&&void 0!==t&&t.isAuthenticated&&this._getActivePrice()}render(){const{heading:e,className:t}=this.props.config,{resources:r}=this.props,a=this.state.products,s="carousel"===this.props.config.layout,i=e&&u.createElement(o.Text,{className:"ms-product-collection__heading",tag:e.tag||"h1",text:e.text,editProps:{onEdit:this.handleHeadingChange,requestContext:this.props.context.request}}),l=p(p({},this.props),{},{heading:i,SingleSlideCarouselComponentProps:{tag:n.SingleSlideCarousel,className:"",flipperPrevLabel:r.flipperPrevious,flipperNextLabel:r.flipperNext,parentId:this.props.id,telemetryContent:this.telemetryContent},ProductCollectionContainer:{moduleProps:this.props,className:d()("ms-product-collection",t)},GridComponentProps:{tag:"ul",className:"ms-product-collection__items"},isCarousel:s,products:a&&a.length>0&&a.map((e,t)=>this._getProduct(e,t)),productPrices:this.productPrices});return this.props.renderView(l)}}t.default=h},Wix4:function(e,t,r){"use strict";r.d(t,"a",(function(){return d}));var a=r("sEfC"),s=r.n(a),n=(r("LR6M"),r("WVYb"),r("mrSG")),i=r("Hxoz"),o=r("okNM"),l=r("cDcd");let c=class extends l.PureComponent{constructor(e){super(e),this.inputRef=l.createRef(),this._validateMin=()=>{const e=void 0===this.props.min?1:this.props.min;isNaN(this.state.currentInput)||this.state.currentInput{this.props.onChange&&this.props.onChange(this.state.currentInput)}):this.props.onChange&&this.props.onChange(this.state.currentInput)},this.state={currentInput:e.currentCount||1,isUpdateing:!1},this._onIncrement=this._onIncrement.bind(this),this._onDecrement=this._onDecrement.bind(this),this._handleChange=this._handleChange.bind(this),this.payLoad=Object(i.getPayloadObject)("click",this.props.telemetryContent,"")}componentDidUpdate(e){this.props.disabled||this.state.currentInput===this.props.currentCount||e.currentCount===this.props.currentCount||this.setState({currentInput:this.props.currentCount||1}),this.props.disabled&&!this.state.isUpdateing&&this.setState({isUpdateing:!0}),!this.props.disabled&&this.state.isUpdateing&&this.setState({currentInput:this.props.currentCount||1,isUpdateing:!1})}render(){const{min:e,max:t}=this.props,r=this.props.decrementGlyphClass+" quantity__controls-glyph",a=this.props.incrementGlyphClass+" quantity__controls-glyph",s=this.state.currentInput<=(e||1)||this.props.isGiftCard,n=this.state.currentInput>=t||this.props.isGiftCard,o=this.state.currentInput;this.payLoad.contentAction.etext=i.TelemetryConstant.DecrementQuantity;const c=Object(i.getTelemetryAttributes)(this.props.telemetryContent,this.payLoad);this.payLoad.contentAction.etext=i.TelemetryConstant.IncrementQuantity;const d=Object(i.getTelemetryAttributes)(this.props.telemetryContent,this.payLoad);let u="";s?u="disabled":this.props.disabled&&(u="transition");let m="";return n?m="disabled":this.props.disabled&&(m="transition"),l.createElement(l.Fragment,null,l.createElement("div",{className:"quantity",id:this.props.id},l.createElement("button",Object.assign({disabled:this.props.disabled||s,title:s?"":this.props.decrementButtonAriaLabel,className:"decrement quantity__controls "+u,onClick:this._onDecrement,"aria-hidden":!0,"aria-label":""+this.props.decrementButtonAriaLabel,tabIndex:-1,color:"secondary"},c),l.createElement("span",{className:r})),l.createElement("input",{type:"number",className:"quantity-input",pattern:"[0-9]*",value:this.state.currentInput,onChange:this._handleChange,onBlur:this._validateMin,"aria-live":"polite","aria-label":""+this.props.inputQuantityAriaLabel,role:"spinbutton","aria-valuemin":e,"aria-valuemax":t,"aria-valuenow":o,ref:this.inputRef,disabled:this.props.disabled}),l.createElement("button",Object.assign({disabled:this.props.disabled||n,title:n?"":this.props.incrementButtonAriaLabel,className:"increment quantity__controls "+m,onClick:this._onIncrement,"aria-hidden":!0,"aria-label":""+this.props.incrementButtonAriaLabel,tabIndex:-1,color:"secondary"},d),l.createElement("span",{className:a}))))}_onIncrement(){let e=!1;const t=this.state.currentInput;let r;t1?(e=!0,r=t-1):(e=!1,r=1),e&&this.props.onChange&&this.props.onChange(r)&&this.setState({currentInput:r})}_handleChange(e){const t=parseInt(e.target.value,10),r=void 0===this.props.min?1:this.props.min,a=this.inputRef&&this.inputRef.current&&this.inputRef.current instanceof HTMLInputElement&&this.inputRef.current;t>this.props.max?this.setState({currentInput:this.props.max},()=>{s()(()=>{this.props.onChange&&this.props.onChange(this.state.currentInput)},200)()}):this.setState({currentInput:t},()=>{s()(()=>{isNaN(this.state.currentInput)||this.state.currentInput{const e=void 0===this.props.min?1:this.props.min;isNaN(this.state.currentInput)||this.state.currentInputthis.props.currentCount,()=>{this.setState({currentInput:this.props.currentCount||1})})}render(){const e=this.props.decrementGlyphClass+" quantity__controls-glyph",t=this.props.incrementGlyphClass+" quantity__controls-glyph",r=this.props.currentCount===this.props.min,a=this.props.currentCount===this.props.max,s=this.state.currentInput;let n="";r?n="disabled":this.props.disabled&&(n="transition");const i=e=>()=>this._onIncrementalChange(e);return o.createElement("div",{className:"quantity"},o.createElement("button",{disabled:this.props.disabled||r,title:r?"":this.props.decrementButtonAriaLabel,className:"decrement quantity__controls "+n,onClick:i(-1),"aria-hidden":!0,"aria-label":""+this.props.decrementButtonAriaLabel,tabIndex:-1,color:"secondary"},o.createElement("span",{className:e})),o.createElement("input",{type:"number",className:"quantity-input",pattern:"[0-9]*",value:s,onChange:this._handleChange,onBlur:this._validateMin,"aria-live":"polite","aria-label":""+this.props.inputQuantityAriaLabel,role:"spinbutton","aria-valuemin":1,"aria-valuemax":this.props.max,"aria-valuenow":s,ref:this.inputRef,disabled:this.props.disabled}),o.createElement("button",{disabled:this.props.disabled||a,title:a?"":this.props.incrementButtonAriaLabel,className:"increment quantity__controls "+(a?"disabled":""),onClick:i(1),"aria-hidden":!0,"aria-label":""+this.props.incrementButtonAriaLabel,tabIndex:-1,color:"secondary"},o.createElement("span",{className:t})))}_onIncrementalChange(e){const t=this.state.currentInput+e;t>=1&&t<=this.props.max&&this.props.onChange&&this.props.onChange(t)}_handleChange(e){const t=parseInt(e.target.value,10),r=void 0===this.props.min?1:this.props.min,a=this.inputRef&&this.inputRef.current&&this.inputRef.current instanceof HTMLInputElement&&this.inputRef.current;t>this.props.max?this.setState({currentInput:this.props.max},()=>{d()(()=>{this.props.onChange&&this.props.onChange(this.state.currentInput)},200)()}):this.setState({currentInput:t},()=>{d()(()=>{isNaN(this.state.currentInput)||this.state.currentInput{const{orderTemplateLine:t,productListLine:r,quantity:a,handlers:s}=e,{LineId:n}=r,{onAddToBag:i,onRemoveItem:o}=s;return{getAddToBag:()=>e=>n&&t.fullProduct&&i(t.fullProduct.ProductDetails,a,n),getRemoveItem:()=>t=>n&&o(e.orderTemplateLine)}},b=e=>{const{addToBagButtonText:t,removeFromOrderTemplateLinesText:r}=e.resources,[a,n]=Object(o.useState)(!1);return l.a.createElement("div",{className:"ms-table__row-links-minified"},l.a.createElement(s.Button,{className:"ms-table__row-links-toggle","data-type":e.index,onClick:e=>{n(!a)}}),a&&l.a.createElement("div",{className:"ms-table__row-links"},l.a.createElement(s.Button,{className:"ms-table__row-links-view",onClick:t=>{e.toggleDetailsDisplayed(e)},title:"View product details"},"View"),f(!0,e.removeButtonClassName,e.isMobile?r:"",y(e).getRemoveItem()),f(!0,e.addButtonClassName,e.isMobile?t:"",y(e).getAddToBag())))},f=(e,t,r,a)=>l.a.createElement(s.Button,{className:t,onClick:a,title:r},r),T=e=>{const{orderTemplateLine:t,productListLine:r,price:s,context:n,imageSettings:i,quantity:o,resources:c,isMobile:d}=e,u=t.fullProduct,{LineId:m,UnitOfMeasure:p}=r,{removeFromOrderTemplateLinesText:h,addToBagButtonText:g}=c;if(!u)return null;const{ItemId:T,Name:_,PrimaryImageUrl:O}=u.ProductDetails,P=Object(a.getFallbackImageUrl)(T,n.actionContext.requestContext.apiSettings),N=e.isMobile?"ms-table__row-links-add":"ms-order-template-table-line__product-add-button",E=e.isMobile?"ms-table__row-links-delete":"ms-order-template-table-line__product-remove-button";return{isMobile:d,selectLine:l.a.createElement("label",{className:"checkbox-container"},l.a.createElement("input",{type:"checkbox",checked:t.isChecked,"aria-checked":t.isChecked,onChange:r=>{t.isChecked=!t.isChecked,e.handlers.onSelect(t,r.target.checked)}}),l.a.createElement("span",{className:"checkmark"})),key:m,productImage:O&&_&&v("ms-order-template-table-line__product-image",n,u.ProductDetails.Name,O,P,i),productInfo:S(e),productPrice:s&&x(e),productNumber:u&&l.a.createElement("div",{className:"ms-order-template-table-line__product-number"},T),productUnitOfMeasure:s?l.a.createElement("div",{className:"ms-order-template-table-line__product-unit-of-measure"},p||s.UnitOfMeasure):void 0,productListId:m,removeButton:f(!0,E,e.isMobile?h:"",y(e).getRemoveItem()),productQuantityView:l.a.createElement("div",null,C(e,m)),productQuantity:o,addToBagButton:f(!0,N,e.isMobile?g:"",y(e).getAddToBag()),popUp:l.a.createElement(b,Object.assign({},e,{addButtonClassName:N,removeButtonClassName:E}))}},_=e=>{const{orderTemplateLine:t,productListLine:r,price:s,context:n,imageSettings:i}=e,o=t.fullProduct,{LineId:l,UnitOfMeasure:c}=r;if(!o)return;const{ItemId:d,Name:u,PrimaryImageUrl:m}=o.ProductDetails,p=Object(a.getFallbackImageUrl)(d,n.actionContext.requestContext.apiSettings);return{productImage:m&&u&&v("thumbnail",n,o.ProductDetails.Name,m,p,i),productInfo:S(e),productPrice:s&&x(e),productNumber:d,productUnitOfMeasure:c||(null==s?void 0:s.UnitOfMeasure),productQuantityView:C(e,l)}},C=(e,t)=>{const{handlers:r,resources:a,quantity:s}=e,{onChangeQuantity:n}=r;return l.a.createElement(g,{currentCount:s,onChange:r=>{n&&n(t,r,e)},max:Number.MAX_VALUE,inputQuantityAriaLabel:a.inputQuantityAriaLabel})},v=(e,t,r,a,s,n)=>{const o={viewports:{xs:{q:"w=64&h=64&m=6",w:0,h:0},lg:{q:"w=64&h=64&m=6",w:0,h:0},xl:{q:"w=64&h=64&m=6",w:0,h:0}},lazyload:!0};return a?l.a.createElement(i.Image,{className:e,altText:r,title:r,src:a,fallBackSrc:s,gridSettings:t.request.gridSettings,imageSettings:n||o,loadFailureBehavior:"empty"}):null},x=e=>{const{price:t,context:r,moduleId:a,moduleTypeName:s,resources:i}=e;return t?l.a.createElement(n.k,{id:a,typeName:s,data:{price:t},className:"ms-order-template-table-line__product-price",freePriceText:i.freePriceText,originalPriceText:i.originalPriceText,currentPriceText:i.currentPriceText,context:r}):null},S=e=>{var t;const{orderTemplateLine:r,productUrl:a}=e,s=null===(t=r.fullProduct)||void 0===t?void 0:t.ProductDetails.Name,n=(e=>{const{orderTemplateLine:t}=e;return t.fullProduct&&t.fullProduct.ProductDetails.Dimensions?t.fullProduct.ProductDetails.Dimensions.map(e=>{if(e.DimensionValue&&e.DimensionValue.Value)return e.DimensionValue.Value}):[]})(e);if(!r.fullProduct||!r.fullProduct.ProductDetails.Dimensions)return[];const i=a?l.a.createElement("a",{className:"ms-order-template-table-line__product-info-name",href:a},s):l.a.createElement("div",{className:"ms-order-template-table-line__product-info-name"},s);return l.a.createElement("div",{className:"ms-order-template-table-line__product-info"},l.a.createElement("div",{className:"ms-order-template-table-line__product-info-name"},i),l.a.createElement("div",{className:"ms-order-template-table-line__product-info-dimension"},n.length&&n.join(", ")))};var O=r("TSYQ"),P=r.n(O);const N=e=>{let{className:t,errorType:r,text:a}=e;switch(r){case"EMPTY":return o.createElement("p",{className:P()("ms-order-template-lines__message-empty",t)},a);case"FAILED":return o.createElement("p",{className:P()("ms-order-template-lines__message-failed",t)},a);case"LOADING":default:return o.createElement("p",{className:"ms-order-template-lines__message-waiting"},a)}};class E extends o.PureComponent{constructor(){super(...arguments),this.state={isChecked:!1},this.componentClassName="ms-table",this.getOnChange=()=>e=>{this.setState({isChecked:!this.state.isChecked},()=>{this.props.clickHandler(this.state.isChecked)})}}componentDidUpdate(e){this.setState({isChecked:!this.props.lines.filter(e=>!e.isChecked).length})}render(){return o.createElement("thead",null,o.createElement("tr",{className:this.componentClassName+"__heading-row"},o.createElement("th",null,o.createElement("label",{className:"checkbox-container"},o.createElement("input",{type:"checkbox","aria-checked":this.state.isChecked,checked:this.state.isChecked,onChange:this.getOnChange()}),o.createElement("span",{className:"checkmark"}))),o.createElement("th",null),o.createElement("th",null,this.props.productNumber),this.props.isMobile?null:o.createElement("th",null,this.props.productName),this.props.isMobile?null:o.createElement("th",null,this.props.productUnitPrice),this.props.isMobile?null:o.createElement("th",null,this.props.productUOM),this.props.isMobile?null:o.createElement("th",null,this.props.productQuantity),this.props.isMobile?o.createElement("td",null):o.createElement("th",null,this.props.productActions)))}}const L=e=>{const{resources:t}=e,{deleteTemplateButtonText:r}=t;return{addTemplateToBag:D(e),renameTemplate:w(e),removeTemplate:o.createElement(s.Button,{className:"ms-order-template-action-bar__delete-template-button",onClick:t=>I(e)},r)}},I=e=>{const{data:{orderTemplate:t},handlers:r}=e,{onRemoveTemplate:a}=r;a&&a(t.productList.Id)},D=e=>{const{data:{orderTemplate:t},typeName:r,id:a,context:s,telemetryContent:i,resources:l}=e,{addTemplateToBagButtonText:c,closeWindowButtonText:d,addToCartFailureMessage:u,addToCartSuccessMessage:m,addToCartProcessMessage:p,linesAddedToCartDialogResources:h}=l,g={closeWindowButtonText:d,addToCartFailureMessage:u,addToCartSuccessMessage:m,addToCartProcessMessage:p,linesAddedToCartDialogResources:h};return o.createElement(n.a,{context:s,id:a,typeName:r,data:{orderTemplate:t},className:"",addToCartText:c,dialogStrings:g,telemetryContent:i})},w=e=>{const{renameOrderTemplateDialogStrings:t,resources:r,context:a,handlers:s}=e;return o.createElement(n.o,{onRenameTemplate:s.onRenameTemplate,className:"msc-order-template-name-dialog",context:a,id:e.id,data:{orderTemplate:e.data.orderTemplate.productList},typeName:e.typeName,renameOrderTemplateDialogStrings:t,renameOrderTemplateButtonText:r.renameTemplateButtonText})};class k extends o.PureComponent{constructor(){super(...arguments),this.state={isAddDisabled:!0,isRemoveDisabled:!0},this.addHandler=e=>{this.setState({isAddDisabled:!0}),this.props.onAddSelectionToBag(),this.setState({isAddDisabled:!1})},this.removeHandler=e=>{this.setState({isRemoveDisabled:!0}),this.props.onRemoveSelection()}}componentDidUpdate(e){e.selectedLines.length!==this.props.selectedLines.length&&this.setState({isAddDisabled:!this.props.selectedLines.length,isRemoveDisabled:!this.props.selectedLines.length})}render(){const{addLineModalLinkText:e,searchButtonAriaLabel:t,searchInputAriaLabel:r,searchModalPlaceholderText:a,selectProductButtonText:n,addItemToTemplateText:i,addLineProductUnitPricePrefix:l,backButtonText:c,decrementButtonAriaLabel:d,incrementButtonAriaLabel:u,quantitySelectLabel:m,addLineProductUnitOfMeasurePrefix:p,notFoundSearchErrorNotice:h,notFoundSearchErrorRedediation:g,searchErrorMessage:y,productDimensionTypeColor:b,productDimensionTypeConfiguration:f,productDimensionTypeSize:T,productDimensionTypeStyle:_,addSelectedToBagButtonText:C,removeSelectedToBagButtonText:v,searchResultsCountVerbage:x,searchResultsCountSubject:S,addToTemplateConfirmation:O,totalPriceLabel:P,progressNotificationText:N,addToTemplateDuplicateError:E,addToTemplateGenericError:L,dimensionMissingError:I}=this.props.resources,D={context:this.props.context,resources:{addLineModalLinkText:e,searchButtonAriaLabel:t,searchInputAriaLabel:r,searchModalPlaceholderText:a,selectProductButtonText:n,addItemToTemplateText:i,addLineProductUnitPricePrefix:l,backButtonText:c,decrementButtonAriaLabel:d,incrementButtonAriaLabel:u,quantitySelectLabel:m,addLineProductUnitOfMeasurePrefix:p,notFoundSearchErrorNotice:h,notFoundSearchErrorRedediation:g,searchErrorMessage:y,productDimensionTypeColor:b,productDimensionTypeConfiguration:f,productDimensionTypeSize:T,productDimensionTypeStyle:_,searchResultsCountVerbage:x,searchResultsCountSubject:S,addToTemplateConfirmation:O,totalPriceLabel:P,progressNotificationText:N,addToTemplateDuplicateError:E,addToTemplateGenericError:L,dimensionMissingError:I},imageSettings:this.props.config.imageSettings,orderTemplateId:this.props.orderTemplateId};return o.createElement(o.Fragment,null,o.createElement(U,Object.assign({},D)),o.createElement(s.Button,{onClick:this.addHandler,disabled:this.state.isAddDisabled,className:"add-selected-to-bag","aria-label":C},o.createElement("span",null),!this.props.isMinifiedView&&C),o.createElement(s.Button,{onClick:this.removeHandler,disabled:this.state.isRemoveDisabled,className:"remove-selected","aria-label":v},o.createElement("span",null),!this.props.isMinifiedView&&v))}}r("9VTn");var A,B=r("rePB"),M=r("mwIZ"),R=r.n(M),j=(r("ES/9"),r("BDvt"),r("EawV"),r("Y2vv")),V=e=>o.createElement(o.Fragment,null,o.createElement("div",{className:e.className+"__loading__icon"}),(null==e?void 0:e.msg)&&o.createElement("div",{className:e.className+"__loading__msg"},null==e?void 0:e.msg));function F(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,a)}return r}function q(e){for(var t=1;t{const{resources:{searchButtonAriaLabel:e,searchInputAriaLabel:t,searchModalPlaceholderText:r}}=this.props;return l.a.createElement("form",{className:"msc-add-line-to-template__search-form","aria-label":e,name:"add-line-to-template-search-form",role:"form",autoComplete:"off",onSubmit:this._onSearchSubmit},l.a.createElement("input",{type:"text",autoFocus:!0,"aria-label":t,className:"msc-form-control msc-add-line-to-template__search-input",placeholder:r,value:this.state.query,onChange:this._onInputChange,ref:this.searchTextInput,maxLength:200}),l.a.createElement("button",{className:"msc-add-line-to-template__search-button","aria-label":"Add To Template Search Button",color:"primary"}))},this._onSearchSubmit=e=>{e.preventDefault();const t=R()(this,"searchTextInput.current.value",null);t&&(this.setState({content:A.Loading}),this._getSearchResults(t).then(e=>{0===e.length?this.setState({products:e,content:A.NotFound}):this.setState({products:e,content:A.ProductList})}).catch(e=>{this.setState({content:A.Error})}))},this._onQuantityChangeHandler=e=>{this.setState({selectedQuantity:+e.target.value})},this._onSelectItem=async e=>{const{actionContext:t,request:{apiSettings:{channelId:r}}}=this.props.context,s=new a.SelectedVariantInput(e.RecordId,r,[]),n=await Object(a.getSelectedVariant)(s,t);if(!n)return this.props.context.telemetry.error("Error retrieving product variant"),Promise.resolve([]);const i=await this._getProductDimensions(e);return this.setState({selectedProductDimensions:i,content:A.ProductConfiguration,selectedProduct:n}),i},this._onInputChange=e=>{this.setState({query:e.target.value})},this._onBackButtonClickHandler=()=>{this.setState({content:A.ProductList})},this._highlightSearchTerm=e=>{const t=e&&unescape(e.replace(new RegExp(this.state.query,"i"),"$&"));return l.a.createElement("div",{className:"msc-add-line-to-template__product__name",dangerouslySetInnerHTML:{__html:t||""}})},this._resultCountText=()=>this.props.resources.searchResultsCountVerbage.replace("{count}",this.state.products.length.toString()).replace("{subject}",`${this.props.resources.searchResultsCountSubject}${this.state.products.length>1?"s":""}`),this._addItemToTemplateHandler=async e=>{const{orderTemplateId:t,context:{actionContext:r}}=this.props,s=new a.AddItemToOrderTemplateInput(t,e.product.RecordId,e.quantity,e.product.DefaultUnitOfMeasure||"ea"),n=await Object(a.addItemToOrderTemplate)(s,r);return this.setState({reloadPage:!0}),n},this._toggleModalHandler=()=>{this.setState({isOpen:!this.state.isOpen,content:A.Search}),this.state.reloadPage&&(window.location.reload(),this.setState({reloadPage:!1}))}}onComponentDidMount(){var e;null===(e=this.searchTextInput.current)||void 0===e||e.focus()}onComponentDidUpdate(){var e;null===(e=this.searchTextInput.current)||void 0===e||e.focus()}get showBackArrow(){return this.state.content===A.ProductConfiguration}render(){const{resources:{addLineModalLinkText:e}}=this.props,t=q(q({},this.props),{},{className:"msc-add-line-to-template",toggle:this._toggleModalHandler,isOpen:this.state.isOpen});return l.a.createElement(l.a.Fragment,null,l.a.createElement(s.Modal,Object.assign({},t),l.a.createElement(s.ModalHeader,{toggle:this._toggleModalHandler},this.showBackArrow&&l.a.createElement("button",{type:"button",className:"msc-modal__back-button","aria-label":"Back to search results",onClick:this._onBackButtonClickHandler}),e),this._renderContent()),l.a.createElement(s.Button,{className:"msc-add-line-to-template__button","aria-label":e,onClick:this._toggleModalHandler},l.a.createElement("span",null),e))}_renderContent(){switch(this.state.content){case A.ProductConfiguration:const{selectedProduct:e,selectedProductDimensions:t}=this.state,r=q(q({},this.props),{},{imageSettings:this.props.imageSettings||this.defaultImageSettings,product:e,dimensions:t,addToTemplateHandler:this._addItemToTemplateHandler,onQuantityChangeHandler:this._onQuantityChangeHandler,highlightSearchTerm:this._highlightSearchTerm,searchForm:this._renderSearchForm()});return l.a.createElement($,Object.assign({},r));case A.ProductList:const a=q(q({},this.props),{},{imageSettings:this.props.imageSettings||this.defaultImageSettings,clickHandler:this._onSelectItem,products:this.state.products,highlightSearchTerm:this._highlightSearchTerm,searchForm:this._renderSearchForm(),renderResultCountText:this._resultCountText});return l.a.createElement(s.ModalBody,null,l.a.createElement(z,Object.assign({},a)));case A.Loading:return l.a.createElement(s.ModalBody,null,this._renderSearchForm(),l.a.createElement(V,{className:"msc-add-line-to-template",msg:this.props.resources.progressNotificationText}));case A.NotFound:const{notFoundSearchErrorNotice:n,notFoundSearchErrorRedediation:i}=this.props.resources;return l.a.createElement(s.ModalBody,null,l.a.createElement("p",{className:"msc-add-line-to-template__search-result-count"},this._resultCountText()),this._renderSearchForm(),l.a.createElement(Q,{error:n,msg:i}));case A.Error:return l.a.createElement(s.ModalBody,null,this._renderSearchForm(),l.a.createElement("div",{className:"msc-alert-danger"},this.props.resources.searchErrorMessage));default:return l.a.createElement(s.ModalBody,null,this._renderSearchForm())}}_getSearchResults(e){const{context:{actionContext:t,request:{apiSettings:{channelId:r,catalogId:a}}}}=this.props,s={};return s.Context={ChannelId:r,CatalogId:a},s.IncludeAttributes=!0,s.SearchCondition=e,Object(j.w)({callerContext:t},s)}async _getProductDimensions(e){const{context:{actionContext:t,request:{apiSettings:{channelId:r}}}}=this.props,s=e.MasterProductId?e.MasterProductId:e.RecordId;return Object(a.getDimensionsForSelectedVariant)(new a.GetDimensionsForSelectedVariantInput(s,r,[]),t)}}Object(u.__decorate)([m.e],U.prototype,"showBackArrow",null);class H extends o.PureComponent{constructor(e,t){super(e),this.selectMenu=o.createRef(),this._onChanged=e=>{this.setState({selectedIndex:e.target.value}),this.props.onChange&&this.props.onChange({dropdownId:this.props.dropdownId,selectId:e.target.value,selectedValue:e.target.innerText})},this.state={selectedIndex:""}}componentDidMount(){this.selectMenu.current&&(this.selectMenu.current.selectedIndex=0)}render(){const{dropdownId:e,dropdownList:t,dropdownName:r}=this.props;return o.createElement("select",{id:"msc-dropdown__entry-"+e,ref:this.selectMenu,"aria-label":r,className:"msc-dropdown__select",onChange:this._onChanged},t.map(e=>e&&o.createElement("option",{value:e.id,key:e.id,selected:+this.state.selectedIndex==+e.id,"aria-selected":+this.state.selectedIndex==+e.id},e.value)))}}const Q=e=>o.createElement(o.Fragment,null,o.createElement("div",{className:"msc-add-line-to-template__not-found__icon"}),o.createElement("div",{className:"msc-add-line-to-template__not-found__msg"},e.error),o.createElement("div",{className:"msc-add-line-to-template__not-found__remediation-instructions"},e.msg));r("HBRN"),r("Mqeb");function W(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,a)}return r}function G(e){for(var t=1;tthis.props.resources.dimensionMissingError.replace(/\{dimensionName\}/g,e),this._addToTemplateHandler=async e=>{this.setState({isBusy:!0,showAddConfirmation:!1,errors:G(G({},this.state.errors),{},{add:void 0})});const t=this.state.dimensions.map(e=>e.DimensionTypeValue.toString()).filter(e=>!this.selectedDimensions[e]);this.setState({errors:{dimension:t}}),t.length?this.setState({isBusy:!1}):this.props.addToTemplateHandler(G({},this.state)).then(e=>{e.ProductListId&&this.setState({isBusy:!1,showAddConfirmation:!0})}).catch(e=>{const{addToTemplateDuplicateError:t,addToTemplateGenericError:r}=this.props.resources;let a;a="Microsoft_Dynamics_Commerce_Runtime_DuplicateObject"===e.error.name?t:r,this.setState({isBusy:!1,errors:G(G({},this.state.errors),{},{add:a})}),this.props.context.telemetry.error("Error adding item to order template")})},this._onQuantityChange=e=>{this.setState({quantity:e,totalPrice:e*this.props.product.Price})},this._updateDimensionValue=(e,t)=>{if(t&&e.DimensionValues)return e.DimensionValues.find(e=>e.RecordId===+t)},this._onDimensionChanged=async e=>{var t,r;const{product:s,dimensions:n,context:i}=this.props,{actionContext:o,request:{apiSettings:{channelId:l}}}=i,c=null===(t=this.state.errors)||void 0===t||null===(r=t.dimension)||void 0===r?void 0:r.filter(t=>t!==e.dropdownId.toString());this.setState({isBusy:!1,showAddConfirmation:!1,buttonDisabled:!0,errors:{add:void 0,dimension:c}}),this.selectedDimensions[e.dropdownId]=+e.selectId;const d=null==n?void 0:n.map(e=>({DimensionTypeValue:e.DimensionTypeValue,DimensionValue:this._updateDimensionValue(e,this.selectedDimensions[e.DimensionTypeValue])||e.DimensionValue,ExtensionProperties:e.ExtensionProperties})).filter(e=>e&&e.DimensionValue),u=await Object(a.getSelectedVariant)(new a.SelectedVariantInput(s.MasterProductId?s.MasterProductId:s.RecordId,l,d),o);if(!u)return void this.props.context.telemetry.error("Error retrieving variant product for product "+(s.MasterProductId?s.MasterProductId:s.RecordId));const m=new a.GetDimensionsForSelectedVariantInput(u.RecordId,l,d),p=await Object(a.getDimensionsForSelectedVariant)(m,o);if(!p)return this.props.context.telemetry.error("Error retrieving dimensions for reconfigured product variant"),void this.setState({buttonDisabled:!1});const h=new a.ProductAvailabilitiesForSelectedVariantInput(s.MasterProductId?s.MasterProductId:s.RecordId,l),g=await Object(a.getProductAvailabilitiesForSelectedVariant)(h,o),y=new a.PriceForSelectedVariantInput(s.RecordId,l),b=await Object(a.getPriceForSelectedVariant)(y,o);if(!b)return this.props.context.telemetry.error("Error retrieving price for reconfigured product variant"),void this.setState({buttonDisabled:!1});this.setState({buttonDisabled:!1,productAvailableQuantity:g&&g[0]||void 0,unitPrice:+(b.BasePrice||s.Price),dimensions:p.sort((e,t)=>e.DimensionTypeValue-t.DimensionTypeValue),product:u})},this._getDropdownName=(e,t)=>{switch(e){case 1:return t.productDimensionTypeColor;case 2:return t.productDimensionTypeConfiguration;case 3:return t.productDimensionTypeSize;case 4:return t.productDimensionTypeStyle;default:return""}},this.state={quantity:1,unitPrice:e.product.Price,totalPrice:e.product.Price,product:e.product,dimensions:e.dimensions.sort((e,t)=>e.DimensionTypeValue-t.DimensionTypeValue),selectedDimensions:{},buttonDisabled:!1,showAddConfirmation:!1}}render(){const{context:{actionContext:{requestContext:{apiSettings:e}},request:{gridSettings:t}},resources:{addItemToTemplateText:r,addLineProductUnitPricePrefix:n,decrementButtonAriaLabel:o,incrementButtonAriaLabel:c,quantitySelectLabel:d,addLineProductUnitOfMeasurePrefix:u,totalPriceLabel:m},imageSettings:p,highlightSearchTerm:h}=this.props,{buttonDisabled:y,product:b,quantity:f,unitPrice:T,totalPrice:_,showAddConfirmation:C,errors:v}=this.state;return l.a.createElement(l.a.Fragment,null,l.a.createElement(s.ModalBody,null,this.props.searchForm,l.a.createElement("div",{className:"msc-add-line-to-template__product-config"},l.a.createElement("div",{className:"msc-add-line-to-template__product__positioning-container-2"},l.a.createElement("div",{className:"msc-add-line-to-template__product__positioning-container-1"},l.a.createElement(i.Image,{src:(null==b?void 0:b.PrimaryImageUrl)||"",fallBackSrc:Object(a.getFallbackImageUrl)(null==b?void 0:b.ItemId,e)||"",className:"thumbnail",imageSettings:p,gridSettings:t,loadFailureBehavior:"empty"}),l.a.createElement("div",{className:"msc-add-line-to-template__product__attributes"},l.a.createElement("div",{className:"msc-add-line-to-template__product__id"},null==b?void 0:b.ItemId),h((null==b?void 0:b.Name)||""),l.a.createElement("div",{className:"msc-add-line-to-template__product__unit-price"},n," ",this._formatPrice(T)),l.a.createElement("div",{className:"msc-add-line-to-template__product__uom"},u," ",null==b?void 0:b.DefaultUnitOfMeasure))),l.a.createElement("div",{className:"msc-add-line-to-template__product-config__dimensions"},this._getDimensionsNodes())),l.a.createElement("div",{className:"quantity-container"},l.a.createElement("div",null,d),l.a.createElement(g,{id:"msc-add-line-to-template__product-config__quantity",currentCount:f,onChange:this._onQuantityChange,inputQuantityAriaLabel:"Press to increment quantity by 1",max:1e7,decrementButtonAriaLabel:o,incrementButtonAriaLabel:c}))),l.a.createElement("div",{className:"msc-add-line-to-template__product__total-price"},m," ",this._formatPrice(_))),l.a.createElement(s.ModalFooter,null,C&&l.a.createElement("div",{className:"msc-add-line-to-template__add-success msc-alert-success msc-alert"},l.a.createElement("span",{"aria-hidden":"true"}),this._getConfirmationMessage()),(null==v?void 0:v.add)&&l.a.createElement("div",{className:"msc-add-line-to-template__add-error msc-alert-danger msc-alert"},l.a.createElement("span",{className:"msi-exclamation-triangle","aria-hidden":"true"}),null==v?void 0:v.add),l.a.createElement(s.Button,{className:P()("msc-add-line-to-template__add-configured-product-button",{"is-busy":this.state.isBusy}),"aria-label":r,onClick:this._addToTemplateHandler,disabled:y},r)))}_getConfirmationMessage(){const e=this.state.dimensions.map(e=>{var t,r;let a=null===(t=e.DimensionValues)||void 0===t||null===(r=t.find(t=>t.RecordId===this.selectedDimensions[e.DimensionTypeValue]))||void 0===r?void 0:r.Value;return 3===e.DimensionTypeValue&&(a="size "+a),a}).filter(e=>e);return this.props.resources.addToTemplateConfirmation.replace("{count}",this.state.quantity.toString()).replace("{productAndDimensions}",`${this.state.product.Name}, ${Object.values(e).join(", ")}`)}_getDimensionsNodes(){const{dimensions:e}=this.state,{resources:t}=this.props;return null==e?void 0:e.map(e=>{var r,a;const{DimensionValues:n,DimensionTypeValue:i}=e,o=this._getDropdownName(i,t),c=n?n.map(e=>({id:e.RecordId,value:e.Value||""})):[];return c.unshift({id:0,value:"Choose a "+o}),l.a.createElement("div",{key:i},l.a.createElement("div",null,o),(null===(r=this.state.errors)||void 0===r||null===(a=r.dimension)||void 0===a?void 0:a.includes(i.toString()))&&l.a.createElement(s.Alert,{color:"danger",assertive:!0,"aria-label":"aria label"},l.a.createElement("div",{className:"msc-alert__header","aria-hidden":"true"},l.a.createElement("span",{className:"msi-exclamation-triangle"}),l.a.createElement("span",null,this._getDimensionsError(o)))),l.a.createElement(H,{dropdownId:i,dropdownName:this._getDropdownName(i,t),dropdownList:c,onChange:this._onDimensionChanged}))})}_formatPrice(e){const{context:{cultureFormatter:{formatCurrency:t,currencyCode:r}}}=this.props;return t(e.toFixed(2),r)}}const z=e=>{const{products:t,context:{actionContext:{requestContext:{apiSettings:r}},request:{gridSettings:s},cultureFormatter:{formatCurrency:n,currencyCode:o}},clickHandler:c,highlightSearchTerm:d,renderResultCountText:u,resources:{selectProductButtonText:m},imageSettings:p}=e;return l.a.createElement(l.a.Fragment,null,l.a.createElement("p",{className:"msc-add-line-to-template__search-result-count"},u()),e.searchForm,l.a.createElement("div",{className:"msc-add-line-to-template__product-list"},t.map((e,t)=>{const{Price:u,ItemId:h,Name:g,PrimaryImageUrl:y}=e,b=n(u.toFixed(2),o),f=Object(a.getFallbackImageUrl)(h,r)||"";return l.a.createElement("div",{key:"product-"+t,className:"msc-add-line-to-template__product"},l.a.createElement("div",{className:"msc-add-line-to-template__product__positioning-container-1"},l.a.createElement(i.Image,{src:y||"",fallBackSrc:f,className:"thumbnail",gridSettings:s,imageSettings:p,loadFailureBehavior:"empty"}),l.a.createElement("div",{className:"msc-add-line-to-template__product__attributes"},l.a.createElement("div",{className:"msc-add-line-to-template__product__id"},h),d(g||""))),l.a.createElement("div",{className:"msc-add-line-to-template__product__price-container"},l.a.createElement("span",null,b),l.a.createElement(K,{product:e,buttonText:m,clickHandler:c})))})))},K=e=>{const[t,r]=Object(o.useState)(!1),{product:a,buttonText:n,clickHandler:i}=e;return l.a.createElement(s.Button,{className:P()("msc-add-line-to-template__product__select-button",{"is-busy":t}),"aria-label":n,onClick:async()=>{r(!t),await i(a),r(!t)}},n)}},ZOwJ:function(e,t,r){"use strict";var a=r("KQxK");r.d(t,"Popup",(function(){return a.a}));r("AdTS")},iIeo:function(e,t){},jQEf:function(e,t,r){"use strict";r.r(t);r("9VTn");var a=r("rePB"),s=(r("ES/9"),r("mrSG")),n=r("Hxoz"),i=r("sF6Z"),o=r("TSYQ"),l=r.n(o),c=r("okNM"),d=r("cDcd"),u=r.n(d),m=r("4arB"),p=(r("y/s1"),r("hBpL"));var h=e=>{const[t,r]=Object(d.useState)(!1);return u.a.createElement(u.a.Fragment,null,u.a.createElement(n.Button,{className:"ms-order-template__add-template-button",color:"primary",onClick:()=>{r(!0)}},e.createOrderTemplateText),u.a.createElement(p.i,{className:"msc-order-template-name-dialog",modalOpen:t,isUpdateDialog:!1,setModalOpen:r,context:e.context,id:e.id,data:{},typeName:e.typeName,dialogStrings:e.createOrderTemplateDialogResources,onCancel:()=>{},onSuccess:e.onOrderTemplateCreated}))};function g(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,a)}return r}function y(e){for(var t=1;t{this.setState({isOpen:!1})},this._reloadPage=async()=>{window.location.reload()},this._onRemoveFromOrderTemplateList=e=>{const{context:t,data:r,telemetry:a,resources:s}=this.props,{orderTemplates:n}=r;if(t&&t.actionContext){if(t.request.user.isAuthenticated&&t.request.user.token&&n.result&&n.result[0]&&e){const r=n.result.find(t=>t.productList.Id===e);r?Object(i.c)({callerContext:t.actionContext},r.productList).then().catch(t=>{a.warning("[order-template-list] Unable to delete order template."),a.error(t),this.setState({itemKey:e,headerStatusMessage:s.deleteOrderTemplateFailedText,statusCssString:"danger",messageGlyph:"fas fa-exclamation-triangle",isOpen:!0})}).then(this._reloadPage):a.warning("[order-template-list] Failed to delete order template. Order template was not found")}else a.warning("[order-template-list] Failed to delete order template.")}},this.state={itemKey:"",userMessage:"",headerStatusMessage:"",statusCssString:"success",messageGlyph:"fas fa-check",isOpen:!1}}async componentDidMount(){this.setState({})}render(){const{className:e}=this.props.config,{emptyOrderTemplateText:t,createNewTemplateButtonText:r}=this.props.resources,{orderTemplates:a}=this.props.data,s=a&&a.result;if("LOADING"===a.status){const t=y(y({},this.props),{},{OrderTemplateList:{moduleProps:this.props,className:l()("ms-order-template",e)},status:"LOADING",statusMessage:d.createElement(m.a,{errorType:"LOADING",text:"Loading..."}),heading:d.createElement(n.Heading,{className:"ms-order-template__heading",text:this.props.resources.orderTemplateListTitle})});return this.props.renderView(t)}if(s&&0===s.length){const r=y(y({},this.props),{},{OrderTemplateList:{moduleProps:this.props,className:l()("ms-order-template",e)},status:"EMPTY",statusMessage:d.createElement(m.a,{errorType:"EMPTY",text:t}),heading:d.createElement(n.Heading,{className:"ms-order-template__heading",text:this.props.resources.orderTemplateListTitle})});return this.props.renderView(r)}const i=y(y({},this.props),{},{OrderTemplateList:{moduleProps:this.props,className:l()("ms-order-template",e)},status:"SUCCESS",heading:d.createElement(n.Heading,{className:"ms-order-template__heading",text:this.props.resources.orderTemplateListTitle}),createOrderTemplateButton:d.createElement(h,{context:this.props.context,id:this.props.id,typeName:this.props.typeName,data:{},createOrderTemplateText:r,onOrderTemplateCreated:this._reloadPage,createOrderTemplateDialogResources:this._generateOrderTemplateNameDialogResources(this.props.resources)}),templateHeaderStatusMessage:this.state.isOpen&&this.state.headerStatusMessage&&d.createElement("div",{className:"ms-order-template__products-status"},d.createElement(n.Alert,{color:this.state.statusCssString,isOpen:this.state.isOpen,toggle:this._onDismiss},d.createElement("span",null,this.state.headerStatusMessage))),OrderTemplates:{className:"ms-order-template__list-item",tag:"ul"},OrderTemplate:{className:"ms-order-template__tile",tag:"li"},orderTemplates:s&&this._renderOrderTemplateList(s)});return this.props.renderView(i)}_generateOrderTemplateNameDialogResources(e){return{orderTemplateHeaderLabel:e.createOrderTemplateHeader,orderTemplateTitleLabel:e.orderTemplateTitle,orderTemplateNameAriaLabel:e.orderTemplateNameAriaLabel,orderTemplateDescription:e.createOrderTemplateDescription,defaultOrderTemplateName:e.defaultOrderTemplateName,orderTemplateButtonLabel:e.createOrderTemplateButtonText,orderTemplateCancelButtonLabel:e.cancelNewOrderTemplateCreationButtonText}}_renderOrderTemplateList(e){const{context:t,telemetry:r}=this.props,{imageSettings:a,enableImageProductLink:s}=this.props.config;return e.map((e,n)=>{const i={orderTemplateState:this.state,Id:e.productList.Id,name:e.productList.Name,orderTemplate:e,context:t,imageSettings:a,enableImageProductLink:s,removeFromOrderTemplateListText:"remove",addToBagText:this.props.resources.addToBagButtonText,index:n,itemKey:e.productList.Id,telemetry:r,moduleId:this.props.id,moduleTypeName:this.props.typeName,handlers:{onRemoveOrderTemplate:this._onRemoveFromOrderTemplateList,onDismiss:this._onDismiss},resources:{closeWindowButtonText:this.props.resources.closeWindowButtonText,addToCartFailureMessage:this.props.resources.addToCartFailureMessage,addToCartSuccessMessage:this.props.resources.addToCartSuccessMessage,addToCartProcessMessage:this.props.resources.addToCartProcessMessage,linesAddedToCartDialogResources:{viewCartButtonText:this.props.resources.viewCartButtonText,orderTemplateCloseButtonText:this.props.resources.orderTemplateCloseButtonText,linesAddedToCartHeaderItemsOneText:this.props.resources.linesAddedToCartHeaderItemsOneText,linesAddedToCartHeaderLinesOneText:this.props.resources.linesAddedToCartHeaderLinesOneText,linesAddedToCartHeaderLinesFormatText:this.props.resources.linesAddedToCartHeaderLinesFormatText,linesAddedToCartHeaderMessageText:this.props.resources.linesAddedToCartHeaderMessageText}}};return Object(m.b)(i)})}};b=Object(s.__decorate)([c.a],b);t.default=b},l9BT:function(e,t,r){"use strict";r.r(t);r("9VTn");var a=r("rePB"),s=(r("y/s1"),r("LR6M"),r("Hxoz")),n=r("hBpL"),i=r("TSYQ"),o=r.n(i),l=r("cDcd");const c=e=>{let{closeButtonAriaLabel:t,label:r,telemetryContent:a,onClose:n}=e;const i=Object(s.getPayloadObject)("click",a,s.TelemetryConstant.PromoBannerClose),o=Object(s.getTelemetryAttributes)(a,i);return l.createElement("button",Object.assign({className:"ms-promo-banner__close-button","aria-label":t,onClick:n},o),l.createElement("span",{className:"ms-promo-banner__close-button__label","aria-hidden":!0},r))};var d=r("xT9B");const u=e=>{let{links:t,requestContext:r,onTextChange:a,telemetryContent:s}=e;const n=m(t,s);return l.createElement("span",{className:"ms-promo-banner__links"},n&&n.length?l.createElement(d.Links,{links:n,editProps:{onTextChange:a,requestContext:r}}):null)},m=(e,t)=>{if(!e||0===e.length)return null;const r=[];return e.forEach((e,a)=>{const n=Object(s.getPayloadObject)("click",t,"",""),i=e.linkText?e.linkText:"";n.contentAction.etext=i;const o=Object(s.getTelemetryAttributes)(t,n),l={ariaLabel:e.ariaLabel,className:"ms-promo-banner__link",linkText:e.linkText,linkUrl:e.linkUrl.destinationUrl,openInNewTab:e.openInNewTab,role:"button",additionalProperties:o,onClick:Object(s.onTelemetryClick)(t,n,i)};r.push(l)}),r},p=e=>{let{text:t,onTextChange:r,requestContext:a}=e;return l.createElement(d.Text,{className:"ms-promo-banner__text",tag:"span",text:t,editProps:{onEdit:r,requestContext:a}})};function h(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,a)}return r}function g(e){for(var t=1;t{this.props.config.bannerMessages&&this.props.config.bannerMessages[0]&&(this.props.config.bannerMessages[0].text=e.target.value)},this.handleLinkTextChange=e=>t=>{if(this.props.config.bannerMessages&&this.props.config.bannerMessages[1]){const r=this.props.config.bannerMessages[1].links;r&&(r[e].linkText=t.target.value)}},this._next=()=>{const e=this._isLastItem()?0:this.state.activeIndex+1;this._goToIndex(e)},this._previous=()=>{const e=this._isFirstItem()?this.props.config.bannerMessages?this.props.config.bannerMessages.length-1:0:this.state.activeIndex-1;this._goToIndex(e)},this._goToIndex=e=>{this.state.animating||this.setState({activeIndex:e})},this._isFirstItem=()=>0===this.state.activeIndex,this._isLastItem=()=>this.props.config.bannerMessages&&this.state.activeIndex===this.props.config.bannerMessages.length-1,this._onDismiss=()=>{this.setState({isVisible:!1})}}render(){const{bannerMessages:e,dismissEnabled:t,interval:r,hideFlipper:a,autoplay:s,className:i=""}=this.props.config,{closeButtonAriaLabel:d,closeButtonLabel:m}=this.props.resources,{isVisible:h,activeIndex:y}=this.state;if(!h)return this.props.context.telemetry.error("Promo banner content is empty, module wont render."),null;const b=g(g({},this.props),{},{className:o()("ms-promo-banner",i),isVisible:h,onDismiss:this._onDismiss,handleLinks:this.handleLinkTextChange,handleText:this.handleTextChange,promoBannerProps:{className:o()("ms-promo-banner",i),moduleProps:this.props,role:"banner"},PromoBannerTextProps:{tag:p},PromoBannerLinksProps:{tag:u,telemetryContent:this.telemetryContent},contentProps:{className:"ms-promo-banner__content"},bannerMessages:e,activeIndex:y,CarouselProps:{tag:n.e,className:"ms-promo-banner__carousel",activeIndex:y,next:this._next,previous:this._previous,onIndicatorsClickHandler:this._goToIndex,hideIndicator:a,interval:r,hideFlipper:a,autoplay:s},closeButton:t&&l.createElement(c,Object.assign({},{onClose:this._onDismiss,label:m,closeButtonAriaLabel:d,telemetryContent:this.telemetryContent}))});return this.props.renderView(b)}}t.default=y},o1TC:function(e,t,r){"use strict";r("CG8G"),r("pj7+");var a=r("YkhX");r.d(t,"OrderTemplateActionsView",(function(){return a.b})),r.d(t,"OrderTemplateBulkActions",(function(){return a.c})),r.d(t,"OrderTemplateLineView",(function(){return a.d})),r.d(t,"OrderTemplateLinesStatusMessage",(function(){return a.e})),r.d(t,"OrderTemplateMobileLineView",(function(){return a.f})),r.d(t,"OrderTemplateTableHeading",(function(){return a.g}));r("iIeo"),r("jQEf"),r("xWra"),r("4arB")},"pj7+":function(e,t,r){"use strict";r.r(t);r("LR6M");var a=r("Hxoz"),s=r("cDcd");const n=(e,t,r)=>{if(!e)return null;const{key:n,selectLine:i,productImage:o,productPrice:l,productNumber:c,addToBagButton:d,removeButton:u,productInfo:m,productUnitOfMeasure:p,productQuantityView:h,productQuantity:g,popUp:y,isMobile:b}=e;return s.createElement(a.Node,Object.assign({key:n,className:r.className},r),s.createElement("td",null,i),s.createElement("td",null,o),b?s.createElement("td",null,s.createElement("div",null,c),s.createElement("div",null,t,": ",g)):s.createElement("td",null,c),!b&&s.createElement("td",null,m),!b&&s.createElement("td",null,l),!b&&s.createElement("td",null,p),!b&&s.createElement("td",null,h),b&&s.createElement("td",null,y),!b&&s.createElement("td",null,d,u))};t.default=e=>{const{OrderTemplateLines:t,status:r,statusMessage:i,heading:o,ProductsTable:l,ProductsTableHeading:c,orderLines:d,ProductsTableRow:u,productsStatusMessage:m,OrderTemplateActions:p,orderActions:h,pagination:g,itemAddedToCartDialog:y,bulkOrderLineActions:b,isDetailsDisplayed:f,detailedProductView:T,toggleDetailsDisplayed:_,resources:{cancelBtnLabel:C,productNumberText:v,productText:x,productUnitPriceText:S,productUOMText:O,productQuantityText:P}}=e,N=()=>{_&&_(void 0)};return s.createElement(a.Module,Object.assign({},t),o,p&&s.createElement(a.Node,Object.assign({},p),null==h?void 0:h.addTemplateToBag,null==h?void 0:h.renameTemplate,null==h?void 0:h.removeTemplate,!f&&m),b,"SUCCESS"!==r&&i,l&&d&&d.length>0&&s.createElement(a.Node,{className:"ms-order-template__content"},s.createElement(a.Node,Object.assign({},l),c,s.createElement("tbody",null,d&&d.map(e=>n(e,P,u)))),g),y,s.createElement(a.Modal,{wrapClassName:"ms-order-template-mobile-view-modal",autoFocus:!0,fade:!1,applicationNode:"renderPage",isOpen:f,toggle:N},s.createElement(a.ModalHeader,{toggle:N},"Product Details"),s.createElement(a.ModalBody,null,s.createElement("ul",null,s.createElement("li",null,null==T?void 0:T.productImage),s.createElement("li",{className:"product-info"},s.createElement("span",null,x,":"),null==T?void 0:T.productInfo),s.createElement("li",null,s.createElement("span",null,v,":"),null==T?void 0:T.productNumber),s.createElement("li",null,s.createElement("span",null,S,":")," ",null==T?void 0:T.productPrice),s.createElement("li",null,s.createElement("span",null,O,":")," ",null==T?void 0:T.productUnitOfMeasure),s.createElement("li",null,s.createElement("span",null,P,":"),null==T?void 0:T.productQuantityView),m&&s.createElement("li",null,m))),s.createElement(a.ModalFooter,null,s.createElement(a.Button,{onClick:N},C))))}},vdFq:function(e,t){},xWra:function(e,t,r){"use strict";r.r(t),r.d(t,"OrderTemplateListView",(function(){return n}));r("LR6M");var a=r("cDcd"),s=r("Hxoz"); /*! * Copyright (c) Microsoft Corporation. * All rights reserved. See LICENSE in the project root for license information. */ const n=e=>{const{OrderTemplateList:t,status:r,statusMessage:n,heading:o,OrderTemplates:l,orderTemplates:c,OrderTemplate:d,createOrderTemplateButton:u,templateHeaderStatusMessage:m}=e;return a.createElement(s.Module,Object.assign({},t),o,"SUCCESS"!==r&&n,a.createElement(s.Node,{className:""},u,m),l&&c&&c.length>0&&a.createElement(s.Node,Object.assign({},l),c&&c.map(e=>i(e,d))))},i=(e,t)=>{const{key:r,addToCartButton:n,orderTemplateImage:i,orderTemplateStatusMessage:o,removeButton:l,orderTemplateName:c}=e;return a.createElement(s.Node,Object.assign({key:r,className:t.className},t),c,i,n,l,o)};t.default=n}}]); //# sourceMappingURL=8.7b98c7a31d05cc03.chunk.js.map