"use strict";(self.webpackChunkwebpackWcBlocksStylingJsonp=self.webpackChunkwebpackWcBlocksStylingJsonp||[]).push([[9319],{8901:(e,i,t)=>{t.r(i),t.d(i,{default:()=>R});var o=t(51609),c=t(70851),s=t(41616),n=t(14656),p=t(47143),r=t(47594),a=t(14958),l=t(40812),h=t(99292),g=t(27723),d=t(7104),m=t(63705),u=t(11176),k=t(86087),_=t(18531),w=t(15703),E=t(56713),C=t(18144),b=t(89854);t(93832);var T=t(74845);const x={hidden:!0,message:(0,g.__)("Shipping options are not available","woocommerce")},v=({checked:e,rate:i,showPrice:t,showIcon:s,toggleText:n,multiple:p,onClick:r})=>(0,o.createElement)(T.A,{role:"radio",removeTextWrap:!0,onClick:r,className:(0,c.A)("wc-block-checkout__shipping-method-option",{"wc-block-checkout__shipping-method-option--selected":"pickup"===e})},!0===s&&(0,o.createElement)(d.A,{icon:m.A,size:28,className:"wc-block-checkout__shipping-method-option-icon"}),(0,o.createElement)("span",{className:"wc-block-checkout__shipping-method-option-title"},n),!0===t&&(0,o.createElement)(E.e,{multiple:p,minRate:i.min,maxRate:i.max})),A=({checked:e,rate:i,showPrice:t,showIcon:s,toggleText:n,onClick:a,shippingCostRequiresAddress:l=!1})=>{const h=(0,p.useSelect)((e=>e(r.CART_STORE_KEY).getShippingRates().some((({shipping_rates:e})=>!e.every(_.J_))))),m=l&&(()=>{const e=(0,p.select)("wc/store/validation"),i=e.getValidationError("shipping_state"),t=e.getValidationError("shipping_address_1"),o=e.getValidationError("shipping_country"),c=e.getValidationError("shipping_postcode");return[e.getValidationError("shipping_city"),i,t,o,c].some((e=>void 0!==e))})()&&!h,w=void 0!==i.min&&void 0!==i.max,{setValidationErrors:C,clearValidationError:b}=(0,p.useDispatch)(r.VALIDATION_STORE_KEY);(0,k.useEffect)((()=>{"shipping"!==e||w?b("shipping-rates-error"):C({"shipping-rates-error":x})}),[e,b,w,C]);const v=void 0===i.min||m?(0,o.createElement)("span",{className:"wc-block-checkout__shipping-method-option-price"},(0,g.__)("calculated with an address","woocommerce")):(0,o.createElement)(E.e,{minRate:i.min,maxRate:i.max});return(0,o.createElement)(T.A,{role:"radio",onClick:a,removeTextWrap:!0,className:(0,c.A)("wc-block-checkout__shipping-method-option",{"wc-block-checkout__shipping-method-option--selected":"shipping"===e})},!0===s&&(0,o.createElement)(d.A,{icon:u.A,size:28,className:"wc-block-checkout__shipping-method-option-icon"}),(0,o.createElement)("span",{className:"wc-block-checkout__shipping-method-option-title"},n),!0===t&&v)},S=({checked:e,onChange:i,showPrice:t,showIcon:c,localPickupText:s,shippingText:n})=>{var p,r;const{shippingRates:l}=(0,a.m)(),h=(0,w.getSetting)("shippingCostRequiresAddress",!1),g=(0,w.getSetting)("localPickupText",s||b.A);return(0,o.createElement)("div",{id:"shipping-method",className:"components-button-group wc-block-checkout__shipping-method-container",role:"radiogroup"},(0,o.createElement)(A,{checked:e,onClick:()=>{i("shipping")},rate:(0,C.L)(null===(p=l[0])||void 0===p?void 0:p.shipping_rates),showPrice:t,showIcon:c,shippingCostRequiresAddress:h,toggleText:n||b.x}),(0,o.createElement)(v,{checked:e,onClick:()=>{i("pickup")},rate:(0,C._)(null===(r=l[0])||void 0===r?void 0:r.shipping_rates),multiple:l.length>1,showPrice:t,showIcon:c,toggleText:g}))};var P=t(3530);const R=(0,s.withFilteredAttributes)(P.A)((({title:e,description:i,children:t,className:s,showPrice:g,showIcon:d,shippingText:m,localPickupText:u})=>{const{showFormStepNumbers:k}=(0,h.Oy)(),{checkoutIsProcessing:_,prefersCollection:w}=(0,p.useSelect)((e=>{const i=e(r.CHECKOUT_STORE_KEY);return{checkoutIsProcessing:i.isProcessing(),prefersCollection:i.prefersCollection()}})),{setPrefersCollection:E}=(0,p.useDispatch)(r.CHECKOUT_STORE_KEY),{shippingRates:C,needsShipping:b,hasCalculatedShipping:T,isCollectable:x}=(0,a.m)();return b&&T&&C&&x&&l.F7?(0,o.createElement)(n.FormStep,{id:"shipping-method",disabled:_,className:(0,c.A)("wc-block-checkout__shipping-method",s),title:e,description:i,showStepNumber:k},(0,o.createElement)(S,{checked:w?"pickup":"shipping",onChange:e=>{E("pickup"===e)},showPrice:g,showIcon:d,localPickupText:u,shippingText:m}),t):null}))}}]);