text: (window.webpackJsonpCheckout=window.webpackJsonpCheckout||[]).push([[11],{1830:function(e,t,n){"use strict";n.d(t,"a",(function(){return d}));var i=n(1),s=n(0),r=n.n(s),a=n(2),o=n(6),d=function(){var e=Object(s.useCallback)((function(e){return r.a.createElement(o.o,{hidden:!0,htmlFor:e},r.a.createElement(a.e,{id:"shipping.order_comment_label"}))}),[]),t=Object(s.useCallback)((function(e){var t=e.field;return r.a.createElement(o.r,Object(i.__assign)({},t,{autoComplete:"off",maxLength:2e3}))}),[]),n=Object(s.useMemo)((function(){return r.a.createElement(o.p,null,r.a.createElement(a.e,{id:"shipping.order_comment_label"}))}),[]);return r.a.createElement(o.h,{legend:n,testId:"checkout-shipping-comments"},r.a.createElement(o.k,{input:t,label:e,name:"orderComment"}))}},1835:function(e,t,n){},1847:function(e,t,n){"use strict";n.r(t),n.d(t,"mapToShippingProps",(function(){return ee}));var i=n(1),s=n(3),r=n(0),a=n.n(r),o=n(114),d=n(140),c=n(32),u=n(58),l=n(43),p=n(57),h=n(2),g=function(e){function t(n){var i=e.call(this,{name:"ASSIGN_ITEM_FAILED",message:Object(h.f)().translate("shipping.assign_item_error"),data:n})||this;return Object(p.h)(i,t.prototype),i}return Object(i.__extends)(t,e),t}(p.a),m=function(e){function t(n){var i=e.call(this,{name:"ASSIGN_ITEM_INVALID_ADDRESS",message:Object(h.f)().translate("shipping.assign_item_invalid_address_error"),title:Object(h.f)().translate("shipping.assign_item_invalid_address_error_heading"),data:n})||this;return Object(p.h)(i,t.prototype),i}return Object(i.__extends)(t,e),t}(p.a),S=function(e){function t(n){var i=e.call(this,{name:"UNASSIGN_ITEM_FAILED",message:Object(h.f)().translate("shipping.unassign_item_error"),data:n})||this;return Object(p.h)(i,t.prototype),i}return Object(i.__extends)(t,e),t}(p.a),b=n(641),f=n(948),A=n(55),_=n(9),v=n(6),O=n(946),C=n(642),j=n(462),E=n(947);var y=Object(r.memo)((function(e){var t=e.item,n=t.id,i=t.key,s=t.imageUrl,o=t.quantity,c=t.name,u=t.options,l=t.consignment,p=e.addresses,h=e.onSelectAddress,g=e.onUseNewAddress,m=Object(r.useCallback)((function(e){g(e,n,i)}),[n,g,i]),S=Object(r.useCallback)((function(e){h(e,n,i)}),[n,i,h]);return a.a.createElement("div",{className:"consignment"},a.a.createElement("figure",{className:"consignment-product-figure"},s&&a.a.createElement("img",{alt:c,src:s})),a.a.createElement("div",{className:"consignment-product-body"},a.a.createElement("h5",{className:"optimizedCheckout-contentPrimary"},o+" x "+c),(u||[]).map((function(e){var t=e.name,n=e.value,i=e.nameId;return a.a.createElement("ul",{className:"product-options optimizedCheckout-contentSecondary","data-test":"consigment-item-product-options",key:i},a.a.createElement("li",{className:"product-option"},t+" "+n))})),a.a.createElement(d.c,{addresses:p,onSelectAddress:S,onUseNewAddress:m,selectedAddress:l&&l.shippingAddress})))})),w=n(1830),I=n(67),M=n(42),F=n(475),k=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(i.__extends)(t,e),t.prototype.render=function(){var e=this.props,t=e.cartHasChanged,n=e.isMultiShippingMode,i=e.shouldShowOrderComments,s=e.shouldShowShippingOptions,r=void 0===s||s,o=e.shouldDisableSubmit,d=e.isLoading;return a.a.createElement(a.a.Fragment,null,a.a.createElement(v.h,{id:"checkout-shipping-options",legend:a.a.createElement(a.a.Fragment,null,a.a.createElement(v.p,null,a.a.createElement(h.e,{id:"shipping.shipping_method_label"})),t&&a.a.createElement(I.a,{type:I.b.Error},a.a.createElement("strong",null,a.a.createElement(h.e,{id:"shipping.cart_change_error"}))))},a.a.createElement(F.b,{isMultiShippingMode:n,isUpdatingAddress:d,shouldShowShippingOptions:r})),i&&a.a.createElement(w.a,null),a.a.createElement("div",{className:"form-actions"},a.a.createElement(M.a,{disabled:o,id:"checkout-shipping-continue",isLoading:d,type:"submit",variant:M.c.Primary},a.a.createElement(h.e,{id:"common.continue_action"}))))},t}(r.PureComponent),U=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.state={items:[]},t.handleCloseErrorModal=function(){t.setState({createCustomerAddressError:void 0})},t.handleSaveAddress=function(e){return Object(i.__awaiter)(t,void 0,void 0,(function(){var t,n,s,r;return Object(i.__generator)(this,(function(i){switch(i.label){case 0:return t=this.props.createCustomerAddress,(n=this.state.itemAddingAddress)?(s=Object(d.k)(e),[4,this.handleSelectAddress(s,n.itemId,n.key)]):[2];case 1:i.sent(),i.label=2;case 2:return i.trys.push([2,4,,5]),[4,t(s)];case 3:return i.sent(),[3,5];case 4:return r=i.sent(),this.setState({createCustomerAddressError:r}),[3,5];case 5:return this.setState({itemAddingAddress:void 0}),[2]}}))}))},t.handleUseNewAddress=function(e,n,i){var s=t.props,r=s.onUseNewAddress;s.shouldShowAddAddressInCheckout?t.setState({itemAddingAddress:{key:i,itemId:n}}):r(e,n)},t.handleCloseAddAddressForm=function(){t.setState({itemAddingAddress:void 0})},t.handleSelectAddress=function(e,n,s){return Object(i.__awaiter)(t,void 0,void 0,(function(){var t,r,a,o,c,u;return Object(i.__generator)(this,(function(i){switch(i.label){case 0:if(t=this.props,r=t.assignItem,a=t.onUnhandledError,o=t.getFields,!Object(d.i)(e,o(e.countryCode)))return[2,a(new m)];i.label=1;case 1:return i.trys.push([1,3,,4]),[4,r({address:e,lineItems:[{itemId:n,quantity:1}]})];case 2:return c=i.sent().data,this.syncItems(s,e,c),[3,4];case 3:return u=i.sent(),a(new g(u)),[3,4];case 4:return[2]}}))}))},t.shouldDisableSubmit=function(){var e=t.props,n=e.isLoading,i=e.consignments;return n||!Object(C.a)(i)},t.syncItems=function(e,n,s){var r=t.state.items,a=function(e,t,n){var s=t.updatedItemIndex,r=t.address,a=n.cart,o=n.consignments;if(!(s<0||s>=e.length)&&a){var c=a.lineItems.physicalItems.map((function(e){return e.id})),u=(o||[]).find((function(e){return Object(d.h)(e.shippingAddress,r)})),l=function(e,t,n){if(!t||!n)return;var i=t.lineItems.physicalItems.filter((function(t){var n=t.productId,i=t.variantId;return n===e.productId&&i===e.variantId})).map((function(e){return e.id}));return n.lineItemIds.find((function(e){return i.includes(e)}))}(e[s],a,u);return e.map((function(e,t){if(l&&!c.includes(e.id)||t===s){var n=null!=l?l:e.id;return Object(i.__assign)(Object(i.__assign)({},e),{id:n,consignment:Object(E.a)(o||[],n)})}return e}))}}(r,{updatedItemIndex:r.findIndex((function(t){return t.key===e})),address:n},{cart:s.getCart(),consignments:s.getConsignments()});a&&t.setState({items:a})},t}return Object(i.__extends)(t,e),t.getDerivedStateFromProps=function(e,t){var n=e.cart,i=e.consignments;return t&&t.items&&Object(b.a)(n)===t.items.length?null:{items:Object(O.a)(n,i)}},t.prototype.render=function(){var e=this,t=this.props,n=t.addresses,i=t.consignments,s=t.cart,o=t.isGuest,c=t.onSignIn,u=t.onCreateAccount,l=t.cartHasChanged,g=t.shouldShowOrderComments,m=t.isLoading,S=t.getFields,b=t.defaultCountryCode,f=t.countries,A=t.countriesWithAutocomplete,O=t.googleMapsApiKey,C=this.state,E=C.items,w=C.itemAddingAddress,I=C.createCustomerAddressError;return o?a.a.createElement("div",{className:"checkout-step-info"},a.a.createElement(h.e,{id:"shipping.multishipping_guest_intro"})," ",a.a.createElement("a",{"data-test":"shipping-sign-in-link",href:"#",onClick:Object(_.c)(c)},a.a.createElement(h.e,{id:"shipping.multishipping_guest_sign_in"}))," ",a.a.createElement(h.d,{id:"shipping.multishipping_guest_create",onClick:u})):a.a.createElement(r.Fragment,null,a.a.createElement(p.c,{error:I,message:a.a.createElement(a.a.Fragment,null,a.a.createElement(h.e,{id:"address.consignment_address_updated_text"})," ",a.a.createElement(h.e,{id:"customer.create_address_error"})),onClose:this.handleCloseErrorModal,shouldShowErrorCode:!1}),a.a.createElement(d.b,{countries:f,countriesWithAutocomplete:A,defaultCountryCode:b,getFields:S,googleMapsApiKey:O,isLoading:m,isOpen:!!w,onRequestClose:this.handleCloseAddAddressForm,onSaveAddress:this.handleSaveAddress}),a.a.createElement(v.i,null,a.a.createElement("ul",{className:"consignmentList"},E.map((function(t){return a.a.createElement("li",{key:t.key},a.a.createElement(y,{addresses:n,item:t,onSelectAddress:e.handleSelectAddress,onUseNewAddress:e.handleUseNewAddress}))}))),a.a.createElement(k,{cartHasChanged:l,isLoading:m,isMultiShippingMode:!0,shouldDisableSubmit:this.shouldDisableSubmit(),shouldShowOrderComments:g,shouldShowShippingOptions:!Object(j.a)(i,s.lineItems)})))},t}(r.PureComponent),z=Object(h.j)(Object(A.withFormik)({handleSubmit:function(e,t){(0,t.props.onSubmit)(e)},mapPropsToValues:function(e){return{orderComment:e.customerMessage}},enableReinitialize:!0})(U)),N=n(22),L=n(377),P=Object(r.memo)((function(e){var t=e.onChange,n=Object(r.useMemo)((function(){return a.a.createElement(h.e,{id:"billing.use_shipping_address_label"})}),[]);return a.a.createElement(v.b,{id:"sameAsBilling",labelContent:n,name:"billingSameAsShipping",onChange:t})})),D=n(39),x=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.handleFieldValueChange=function(e){return function(n){(0,t.props.onFieldChange)(e,n)}},t}return Object(i.__extends)(t,e),t.prototype.componentDidMount=function(){return Object(i.__awaiter)(this,void 0,void 0,(function(){var e,t,n,r,a,o;return Object(i.__generator)(this,(function(i){switch(i.label){case 0:e=this.props,t=e.initialize,n=e.methodId,r=e.onUnhandledError,a=void 0===r?s.noop:r,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,t({methodId:n})];case 2:return i.sent(),[3,4];case 3:return o=i.sent(),a(o),[3,4];case 4:return[2]}}))}))},t.prototype.componentWillUnmount=function(){return Object(i.__awaiter)(this,void 0,void 0,(function(){var e,t,n,r,a,o;return Object(i.__generator)(this,(function(i){switch(i.label){case 0:e=this.props,t=e.deinitialize,n=e.methodId,r=e.onUnhandledError,a=void 0===r?s.noop:r,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,t({methodId:n})];case 2:return i.sent(),[3,4];case 3:return o=i.sent(),a(o),[3,4];case 4:return[2]}}))}))},t.prototype.render=function(){var e=this,t=this.props,n=t.containerId,i=t.formFields,s=t.methodId;return a.a.createElement(a.a.Fragment,null,a.a.createElement("div",{className:"widget address-widget widget--"+s,id:n,tabIndex:-1}),a.a.createElement(v.h,null,i.filter((function(e){return e.custom})).map((function(t){return a.a.createElement(v.f,{field:t,key:t.id+"-"+t.name,onChange:e.handleFieldValueChange(t.name),parentFieldName:"shippingAddress.customFields"})}))))},t}(r.PureComponent),V=n(78),W="shippingAddress",R=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.setFieldValue=function(e,n){var i=t.props,s=i.formik.setFieldValue,r=i.formFields.filter((function(e){return e.custom})).map((function(e){return e.name})).includes(e)?"customFields."+e:e;s(W+"."+r,n)},t.handleChange=function(e,n){(0,t.props.onFieldChange)(e,n)},t.handleAutocompleteToggle=function(e){var n=e.isOpen,i=e.inputValue,s=t.props.onFieldChange;n||s("address1",i)},t}return Object(i.__extends)(t,e),t.prototype.render=function(){var e=this.props,t=e.addresses,n=e.address,i=e.onAddressSelect,s=e.onUseNewAddress,r=e.shouldShowSaveAddress,o=e.countries,c=e.countriesWithAutocomplete,u=e.formFields,p=e.isLoading,h=e.googleMapsApiKey,g=e.formik.values.shippingAddress,m=t&&t.length>0,S=Object(d.j)(n,t,u);return a.a.createElement(v.h,{id:"checkoutShippingAddress"},m&&a.a.createElement(v.h,{id:"shippingAddresses"},a.a.createElement(l.c,{isLoading:p},a.a.createElement(d.c,{addresses:t,onSelectAddress:i,onUseNewAddress:s,selectedAddress:S?n:void 0}))),!S&&a.a.createElement(l.c,{isLoading:p,unmountContentWhenLoading:!0},a.a.createElement(d.a,{countries:o,countriesWithAutocomplete:c,countryCode:g&&g.countryCode,fieldName:W,formFields:u,googleMapsApiKey:h,onAutocompleteToggle:this.handleAutocompleteToggle,onChange:this.handleChange,setFieldValue:this.setFieldValue,shouldShowSaveAddress:r})))},t}(r.Component),T=Object(V.a)(R),B=(n(1835),function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.handleFieldValueChange=function(e){return function(n){(0,t.props.onFieldChange)(e,n)}},t}return Object(i.__extends)(t,e),t.prototype.componentDidMount=function(){return Object(i.__awaiter)(this,void 0,void 0,(function(){var e,t,n,r,a,o;return Object(i.__generator)(this,(function(i){switch(i.label){case 0:e=this.props,t=e.initialize,n=e.methodId,r=e.onUnhandledError,a=void 0===r?s.noop:r,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,t({methodId:n})];case 2:return i.sent(),[3,4];case 3:return o=i.sent(),a(o),[3,4];case 4:return[2]}}))}))},t.prototype.componentWillUnmount=function(){return Object(i.__awaiter)(this,void 0,void 0,(function(){var e,t,n,r,a,o;return Object(i.__generator)(this,(function(i){switch(i.label){case 0:e=this.props,t=e.deinitialize,n=e.methodId,r=e.onUnhandledError,a=void 0===r?s.noop:r,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,t({methodId:n})];case 2:return i.sent(),[3,4];case 3:return o=i.sent(),a(o),[3,4];case 4:return[2]}}))}))},t.prototype.render=function(){var e=this,t=this.props,n=t.address,i=t.buttonId,s=t.formFields,r=t.isLoading,o=s.filter((function(e){return e.custom})),c=o.length>0;return a.a.createElement(l.c,{isLoading:r},a.a.createElement("div",{className:"stepHeader",style:{padding:0}},a.a.createElement("div",{className:"stepHeader-body subheader"},a.a.createElement(d.e,{address:n})),a.a.createElement("div",{className:"stepHeader-actions subheader"},a.a.createElement(M.a,{id:i,onClick:Object(_.c)(),size:M.b.Tiny,testId:"step-edit-button",variant:M.c.Secondary},a.a.createElement(h.e,{id:"common.edit_action"})))),c&&a.a.createElement(v.h,{id:"customFieldset"},o.map((function(t){return a.a.createElement(v.f,{field:t,key:t.id+"-"+t.name,onChange:e.handleFieldValueChange(t.name),parentFieldName:"shippingAddress.customFields"})}))))},t}(r.PureComponent)),K=Object(r.memo)((function(e){var t=e.methodId,n=e.formFields,o=e.countries,d=e.countriesWithAutocomplete,c=e.consignments,u=e.googleMapsApiKey,l=e.onAddressSelect,p=e.onFieldChange,h=e.onUseNewAddress,g=e.initialize,m=e.deinitialize,S=e.isLoading,b=e.shippingAddress,f=e.hasRequestedShippingOptions,A=e.addresses,_=e.shouldShowSaveAddress,O=e.onUnhandledError,C=void 0===O?s.noop:O,j=e.isShippingStepPending,E=Object(r.useContext)(v.j).setSubmitted,y=Object(r.useCallback)(Object(D.memoizeOne)((function(e){return function(t){return g(Object(i.__assign)(Object(i.__assign)({},e),t))}})),[]);if(t){var w={};if("amazon"===t)return w={amazon:{container:"addressWidget",onError:C}},a.a.createElement(x,{containerId:"addressWidget",deinitialize:m,formFields:n,initialize:y(w),methodId:t,onFieldChange:p});if("amazonpay"===t&&b){return w={amazonpay:{editAddressButtonId:"edit-ship-button"}},a.a.createElement(B,{address:b,buttonId:"edit-ship-button",deinitialize:m,formFields:n,initialize:y(w),isLoading:j,methodId:t,onFieldChange:p})}}return a.a.createElement(T,{address:b,addresses:A,consignments:c,countries:o,countriesWithAutocomplete:d,formFields:n,googleMapsApiKey:u,isLoading:S,onAddressSelect:l,onFieldChange:function(e,t){f&&E(!0),p(e,t)},onUseNewAddress:h,shouldShowSaveAddress:_})})),G=["address1","postalCode","countryCode","city","stateOrProvince","stateOrProvinceCode"],H=1700,q=function(e){function t(t){var n=e.call(this,t)||this;n.state={isResettingAddress:!1,isUpdatingShippingData:!1,hasRequestedShippingOptions:!1},n.shouldDisableSubmit=function(){var e=n.props,t=e.isLoading,i=e.consignments,s=e.isValid,r=n.state.isUpdatingShippingData;return!!s&&(t||r||!Object(C.a)(i))},n.handleFieldChange=function(e){return Object(i.__awaiter)(n,void 0,void 0,(function(){var t,n,s;return Object(i.__generator)(this,(function(i){switch(i.label){case 0:return t=this.props.setFieldValue,"countryCode"===e&&(t("shippingAddress.stateOrProvince",""),t("shippingAddress.stateOrProvinceCode","")),[4,new Promise((function(e){return setTimeout(e)}))];case 1:return i.sent(),n=G.includes(e),s=this.state.hasRequestedShippingOptions,this.props.isValid?(this.updateAddressWithFormData(n||!s),[2]):[2]}}))}))},n.handleAddressSelect=function(e){return Object(i.__awaiter)(n,void 0,void 0,(function(){var t,n,r,a,o,c,u;return Object(i.__generator)(this,(function(l){switch(l.label){case 0:t=this.props,n=t.updateAddress,r=t.onUnhandledError,a=void 0===r?s.noop:r,o=t.values,c=t.setValues,this.setState({isResettingAddress:!0}),l.label=1;case 1:return l.trys.push([1,3,4,5]),[4,n(e)];case 2:return l.sent(),c(Object(i.__assign)(Object(i.__assign)({},o),{shippingAddress:Object(d.l)(this.getFields(e.countryCode),e)})),[3,5];case 3:return u=l.sent(),a(u),[3,5];case 4:return this.setState({isResettingAddress:!1}),[7];case 5:return[2]}}))}))},n.onUseNewAddress=function(){return Object(i.__awaiter)(n,void 0,void 0,(function(){var e,t,n,r,a,o,c,u;return Object(i.__generator)(this,(function(l){switch(l.label){case 0:e=this.props,t=e.deleteConsignments,n=e.onUnhandledError,r=void 0===n?s.noop:n,a=e.setValues,o=e.values,this.setState({isResettingAddress:!0}),l.label=1;case 1:return l.trys.push([1,3,4,5]),[4,t()];case 2:return c=l.sent(),a(Object(i.__assign)(Object(i.__assign)({},o),{shippingAddress:Object(d.l)(this.getFields(c&&c.countryCode),c)})),[3,5];case 3:return u=l.sent(),r(u),[3,5];case 4:return this.setState({isResettingAddress:!1}),[7];case 5:return[2]}}))}))};var r=n.props.updateAddress;return n.debouncedUpdateAddress=Object(s.debounce)((function(e,t){return Object(i.__awaiter)(n,void 0,void 0,(function(){return Object(i.__generator)(this,(function(n){switch(n.label){case 0:return n.trys.push([0,,2,3]),[4,r(e,{params:{include:{"consignments.availableShippingOptions":t}}})];case 1:return n.sent(),t&&this.setState({hasRequestedShippingOptions:!0}),[3,3];case 2:return this.setState({isUpdatingShippingData:!1}),[7];case 3:return[2]}}))}))}),H),n}return Object(i.__extends)(t,e),t.prototype.render=function(){var e=this.props,t=e.addresses,n=e.cartHasChanged,i=e.isLoading,s=e.onUnhandledError,r=e.methodId,o=e.shouldShowSaveAddress,d=e.countries,c=e.countriesWithAutocomplete,u=e.googleMapsApiKey,l=e.shippingAddress,p=e.consignments,h=e.shouldShowOrderComments,g=e.initialize,m=e.isValid,S=e.deinitialize,b=e.values.shippingAddress,f=e.isShippingStepPending,A=this.state,_=A.isResettingAddress,O=A.isUpdatingShippingData,C=A.hasRequestedShippingOptions,j=!["amazon","amazonpay"].some((function(e){return e===r}));return a.a.createElement(v.i,{autoComplete:"on"},a.a.createElement(v.h,null,a.a.createElement(K,{addresses:t,consignments:p,countries:d,countriesWithAutocomplete:c,deinitialize:S,formFields:this.getFields(b&&b.countryCode),googleMapsApiKey:u,hasRequestedShippingOptions:C,initialize:g,isLoading:_,isShippingStepPending:f,methodId:r,onAddressSelect:this.handleAddressSelect,onFieldChange:this.handleFieldChange,onUnhandledError:s,onUseNewAddress:this.onUseNewAddress,shippingAddress:l,shouldShowSaveAddress:o}),j&&a.a.createElement("div",{className:"form-body"},a.a.createElement(P,null))),a.a.createElement(k,{cartHasChanged:n,isLoading:i||O,isMultiShippingMode:!1,shouldDisableSubmit:this.shouldDisableSubmit(),shouldShowOrderComments:h,shouldShowShippingOptions:m}))},t.prototype.updateAddressWithFormData=function(e){var t=this.props,n=t.shippingAddress,i=t.values.shippingAddress,s=i&&Object(d.k)(i);s&&!Object(d.h)(s,n)&&(this.setState({isUpdatingShippingData:!0}),this.debouncedUpdateAddress(s,e))},t.prototype.getFields=function(e){return(0,this.props.getFields)(e)},t.contextType=v.j,t}(r.PureComponent),J=Object(h.j)(Object(A.withFormik)({handleSubmit:function(e,t){(0,t.props.onSubmit)(e)},mapPropsToValues:function(e){var t=e.getFields,n=e.shippingAddress;return{billingSameAsShipping:e.isBillingSameAsShipping,orderComment:e.customerMessage,shippingAddress:Object(d.l)(t(n&&n.countryCode),n)}},isInitialValid:function(e){var t=e.shippingAddress,n=e.getFields,i=e.language;return!!t&&Object(d.f)({language:i,formFields:n(t.countryCode)}).isValidSync(t)},validationSchema:function(e){var t=e.language,n=e.getFields;return e.methodId?Object(N.object)({shippingAddress:Object(N.lazy)((function(e){return Object(L.a)({translate:Object(d.g)(t),formFields:n(e&&e.countryCode)})}))}):Object(N.object)({shippingAddress:Object(N.lazy)((function(e){return Object(d.f)({language:t,formFields:n(e&&e.countryCode)})}))})},enableReinitialize:!1})(q)),Z=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(i.__extends)(t,e),t.prototype.render=function(){var e=this.props,t=e.addresses,n=e.assignItem,i=e.cart,s=e.cartHasChanged,r=e.createCustomerAddress,o=e.consignments,d=e.countries,c=e.countriesWithAutocomplete,u=e.onCreateAccount,l=e.customerMessage,p=e.deinitialize,h=e.deleteConsignments,g=e.getFields,m=e.googleMapsApiKey,S=e.initialize,b=e.isBillingSameAsShipping,f=e.isGuest,A=e.isLoading,_=e.isMultiShippingMode,v=e.methodId,O=e.onMultiShippingSubmit,C=e.onSignIn,j=e.onSingleShippingSubmit,E=e.onUnhandledError,y=e.onUseNewAddress,w=e.shippingAddress,I=e.shouldShowOrderComments,M=e.shouldShowSaveAddress,F=e.shouldShowAddAddressInCheckout,k=e.signOut,U=e.updateAddress,N=e.isShippingStepPending;return _?a.a.createElement(z,{addresses:t,assignItem:n,cart:i,cartHasChanged:s,consignments:o,countries:d,countriesWithAutocomplete:c,createCustomerAddress:r,customerMessage:l,defaultCountryCode:null==w?void 0:w.countryCode,getFields:g,googleMapsApiKey:m,isGuest:f,isLoading:A,onCreateAccount:u,onSignIn:C,onSubmit:O,onUnhandledError:E,onUseNewAddress:y,shouldShowAddAddressInCheckout:F,shouldShowOrderComments:I}):a.a.createElement(J,{addresses:t,cartHasChanged:s,consignments:o,countries:d,countriesWithAutocomplete:c,customerMessage:l,deinitialize:p,deleteConsignments:h,getFields:g,googleMapsApiKey:m,initialize:S,isBillingSameAsShipping:b,isLoading:A,isMultiShippingMode:_,isShippingStepPending:N,methodId:v,onSubmit:j,onUnhandledError:E,shippingAddress:w,shouldShowOrderComments:I,shouldShowSaveAddress:M,signOut:k,updateAddress:U})},t}(r.Component),Q=Object(h.j)(Z),X=Object(r.memo)((function(e){var t=e.isMultiShippingMode,n=e.isGuest,i=e.onMultiShippingChange,s=e.shouldShowMultiShipping;return a.a.createElement("div",{className:"form-legend-container"},a.a.createElement(v.p,{testId:"shipping-address-heading"},a.a.createElement(h.e,{id:t?n?"shipping.multishipping_address_heading_guest":"shipping.multishipping_address_heading":"shipping.shipping_address_heading"})),s&&a.a.createElement("a",{"data-test":"shipping-mode-toggle",href:"#",onClick:Object(_.c)(i)},a.a.createElement(h.e,{id:t?"shipping.ship_to_single":"shipping.ship_to_multi"})))})),Y=function(e){function t(t){var n=e.call(this,t)||this;return n.handleMultiShippingModeSwitch=function(){return Object(i.__awaiter)(n,void 0,void 0,(function(){var e,t,n,r,a,o,d,c,u;return Object(i.__generator)(this,(function(i){switch(i.label){case 0:if(e=this.props,t=e.consignments,n=e.isMultiShippingMode,r=e.onToggleMultiShipping,a=void 0===r?s.noop:r,o=e.onUnhandledError,d=void 0===o?s.noop:o,c=e.updateShippingAddress,!(n&&t.length>1))return[3,5];this.setState({isInitializing:!0}),i.label=1;case 1:return i.trys.push([1,3,4,5]),[4,c(t[0].shippingAddress)];case 2:return i.sent(),[3,5];case 3:return u=i.sent(),d(u),[3,5];case 4:return this.setState({isInitializing:!1}),[7];case 5:return a(),[2]}}))}))},n.handleSingleShippingSubmit=function(e){var t=e.billingSameAsShipping,s=e.shippingAddress,r=e.orderComment;return Object(i.__awaiter)(n,void 0,void 0,(function(){var e,n,a,o,c,u,l,p,h,g,m,S,b,f;return Object(i.__generator)(this,(function(i){switch(i.label){case 0:e=this.props,n=e.customerMessage,a=e.updateCheckout,o=e.updateShippingAddress,c=e.updateBillingAddress,u=e.navigateNextStep,l=e.onUnhandledError,p=e.shippingAddress,h=e.billingAddress,g=e.methodId,m=s&&Object(d.k)(s),S=[],b=this.hasRemoteBilling(g),Object(d.h)(m,p)||S.push(o(m||{})),t&&m&&!Object(d.h)(m,h)&&!b&&S.push(c(m)),n!==r&&S.push(a({customerMessage:r})),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,Promise.all(S)];case 2:return i.sent(),u(t),[3,4];case 3:return f=i.sent(),l(f),[3,4];case 4:return[2]}}))}))},n.hasRemoteBilling=function(e){return["amazonpay"].some((function(t){return t===e}))},n.handleUseNewAddress=function(e,t){return Object(i.__awaiter)(n,void 0,void 0,(function(){var n,s,r,a;return Object(i.__generator)(this,(function(i){switch(i.label){case 0:n=this.props,s=n.unassignItem,r=n.onUnhandledError,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,s({address:e,lineItems:[{quantity:1,itemId:t}]})];case 2:return i.sent(),location.href="/account.php?action=add_shipping_address&from=checkout",[3,4];case 3:return a=i.sent(),r(new S(a)),[3,4];case 4:return[2]}}))}))},n.handleMultiShippingSubmit=function(e){var t=e.orderComment;return Object(i.__awaiter)(n,void 0,void 0,(function(){var e,n,s,r,a,o;return Object(i.__generator)(this,(function(i){switch(i.label){case 0:e=this.props,n=e.customerMessage,s=e.updateCheckout,r=e.navigateNextStep,a=e.onUnhandledError,i.label=1;case 1:return i.trys.push([1,4,,5]),n===t?[3,3]:[4,s({customerMessage:t})];case 2:i.sent(),i.label=3;case 3:return r(!1),[3,5];case 4:return o=i.sent(),a(o),[3,5];case 5:return[2]}}))}))},n.state={isInitializing:!0},n}return Object(i.__extends)(t,e),t.prototype.componentDidMount=function(){return Object(i.__awaiter)(this,void 0,void 0,(function(){var e,t,n,r,a,o,d,c;return Object(i.__generator)(this,(function(i){switch(i.label){case 0:e=this.props,t=e.loadShippingAddressFields,n=e.loadShippingOptions,r=e.onReady,a=void 0===r?s.noop:r,o=e.onUnhandledError,d=void 0===o?s.noop:o,i.label=1;case 1:return i.trys.push([1,3,4,5]),[4,Promise.all([t(),n()])];case 2:return i.sent(),a(),[3,5];case 3:return c=i.sent(),d(c),[3,5];case 4:return this.setState({isInitializing:!1}),[7];case 5:return[2]}}))}))},t.prototype.render=function(){var e=this.props,t=e.isBillingSameAsShipping,n=e.isGuest,s=e.shouldShowMultiShipping,r=e.customer,o=(e.unassignItem,e.updateShippingAddress),d=e.initializeShippingMethod,c=e.deinitializeShippingMethod,u=e.isMultiShippingMode,p=(e.onToggleMultiShipping,Object(i.__rest)(e,["isBillingSameAsShipping","isGuest","shouldShowMultiShipping","customer","unassignItem","updateShippingAddress","initializeShippingMethod","deinitializeShippingMethod","isMultiShippingMode","onToggleMultiShipping"])),h=this.state.isInitializing;return a.a.createElement("div",{className:"checkout-form"},a.a.createElement(X,{isGuest:n,isMultiShippingMode:u,onMultiShippingChange:this.handleMultiShippingModeSwitch,shouldShowMultiShipping:s}),a.a.createElement(l.c,{isLoading:h,unmountContentWhenLoading:!0},a.a.createElement(Q,Object(i.__assign)({},p,{addresses:r.addresses,deinitialize:c,initialize:d,isBillingSameAsShipping:t,isGuest:n,isMultiShippingMode:u,onMultiShippingSubmit:this.handleMultiShippingSubmit,onSingleShippingSubmit:this.handleSingleShippingSubmit,onUseNewAddress:this.handleUseNewAddress,shouldShowSaveAddress:!n,updateAddress:o}))))},t}(r.Component),$=Object(o.createSelector)((function(e){return e.checkoutService.deleteConsignment}),(function(e){return e.checkoutState.data.getConsignments()}),(function(e,t){return function(){return Object(i.__awaiter)(void 0,void 0,void 0,(function(){return Object(i.__generator)(this,(function(n){switch(n.label){case 0:return t&&t.length?[4,Promise.all(t.map((function(t){var n=t.id;return e(n)})))]:[2];case 1:return[2,n.sent()[0].data.getShippingAddress()]}}))}))}}));function ee(e){var t=e.checkoutService,n=e.checkoutState,i=n.data,s=i.getCart,r=i.getCheckout,a=i.getConfig,o=i.getCustomer,d=i.getConsignments,c=i.getShippingAddress,l=i.getBillingAddress,p=i.getShippingAddressFields,h=i.getShippingCountries,g=n.statuses,m=g.isShippingStepPending,S=g.isSelectingShippingOption,A=g.isLoadingShippingOptions,_=g.isUpdatingConsignment,v=g.isCreatingConsignments,O=g.isCreatingCustomerAddress,C=g.isLoadingShippingCountries,j=g.isUpdatingBillingAddress,E=g.isUpdatingCheckout,y=r(),w=a(),I=d()||[],M=o(),F=s();if(!(y&&w&&M&&F))return null;var k=w.checkoutSettings,U=k.enableOrderComments,z=k.features,N=k.hasMultiShippingEnabled,L=k.googleMapsApiKey,P=Object(f.a)(y),D=Object(b.a)(F),x=A()||S()||_()||v()||j()||E()||O(),V=N&&!P&&D>1&&D<50,W=["US","CA","AU","NZ"];z["CHECKOUT-4183.checkout_google_address_autocomplete_uk"]&&W.push("GB");var R=!V&&I.length>1?void 0:c();return{assignItem:t.assignItemsToAddress,billingAddress:l(),cart:F,consignments:I,countries:h()||u.a,countriesWithAutocomplete:W,customer:M,customerMessage:y.customerMessage,createCustomerAddress:t.createCustomerAddress,deinitializeShippingMethod:t.deinitializeShipping,deleteConsignments:$({checkoutService:t,checkoutState:n}),getFields:p,googleMapsApiKey:L,initializeShippingMethod:t.initializeShipping,isGuest:M.isGuest,isInitializing:C()||A(),isLoading:x,isShippingStepPending:m(),loadShippingAddressFields:t.loadShippingAddressFields,loadShippingOptions:t.loadShippingOptions,methodId:P,shippingAddress:R,shouldShowMultiShipping:V,shouldShowAddAddressInCheckout:z["CHECKOUT-4726.add_address_in_multishipping_checkout"],shouldShowOrderComments:U,signOut:t.signOutCustomer,unassignItem:t.unassignItemsToAddress,updateBillingAddress:t.updateBillingAddress,updateCheckout:t.updateCheckout,updateShippingAddress:t.updateShippingAddress}}t.default=Object(c.d)(ee)(Y)}}]);