(window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[]).push([[27],{19:function(e,t,o){"use strict";var n=o(0),r=o(4),c=o.n(r);t.a=e=>{let t,{label:o,screenReaderLabel:r,wrapperElement:a,wrapperProps:l={}}=e;const s=null!=o,i=null!=r;return!s&&i?(t=a||"span",l={...l,className:c()(l.className,"screen-reader-text")},Object(n.createElement)(t,l,r)):(t=a||n.Fragment,s&&i&&o!==r?Object(n.createElement)(t,l,Object(n.createElement)("span",{"aria-hidden":"true"},o),Object(n.createElement)("span",{className:"screen-reader-text"},r)):Object(n.createElement)(t,l,o))}},291:function(e,t,o){"use strict";o.d(t,"a",(function(){return a}));var n=o(0),r=o(6),c=o(3);o(293);const a=e=>{let{errorMessage:t="",propertyName:o="",elementId:a=""}=e;const{validationError:l,validationErrorId:s}=Object(r.useSelect)(e=>{const t=e(c.VALIDATION_STORE_KEY);return{validationError:t.getValidationError(o),validationErrorId:t.getValidationErrorId(a)}});if(!t||"string"!=typeof t){if(null==l||!l.message||null!=l&&l.hidden)return null;t=l.message}return Object(n.createElement)("div",{className:"wc-block-components-validation-error",role:"alert"},Object(n.createElement)("p",{id:s},t))};t.b=a},293:function(e,t){},294:function(e,t){},295:function(e,t,o){"use strict";var n=o(12),r=o.n(n),c=o(0),a=o(44),l=o(4),s=o.n(l),i=o(146);o(296),t.a=e=>{let{className:t,showSpinner:o=!1,children:n,variant:l="contained",...u}=e;const p=s()("wc-block-components-button",t,l,{"wc-block-components-button--loading":o});return Object(c.createElement)(a.a,r()({className:p},u),o&&Object(c.createElement)(i.a,null),Object(c.createElement)("span",{className:"wc-block-components-button__text"},n))}},296:function(e,t){},311:function(e,t,o){"use strict";o.d(t,"a",(function(){return s}));var n=o(1),r=o(6),c=o(3),a=o(23),l=o(38);const s=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";const{cartCoupons:t,cartIsLoading:o}=Object(l.a)(),{createErrorNotice:s}=Object(r.useDispatch)("core/notices"),{createNotice:i}=Object(r.useDispatch)("core/notices"),{setValidationErrors:u}=Object(r.useDispatch)(c.VALIDATION_STORE_KEY),{applyCoupon:p,removeCoupon:d,isApplyingCoupon:b,isRemovingCoupon:m}=Object(r.useSelect)((e,t)=>{let{dispatch:o}=t;const n=e(c.CART_STORE_KEY),r=o(c.CART_STORE_KEY);return{applyCoupon:r.applyCoupon,removeCoupon:r.removeCoupon,isApplyingCoupon:n.isApplyingCoupon(),isRemovingCoupon:n.isRemovingCoupon(),receiveApplyingCoupon:r.receiveApplyingCoupon}},[s,i]),O=t=>{p(t).then(o=>{!0===o&&i("info",Object(n.sprintf)(
/* translators: %s coupon code. */
Object(n.__)('Coupon code "%s" has been applied to your cart.',"woocommerce"),t),{id:"coupon-form",type:"snackbar",context:e})}).catch(e=>{u({coupon:{message:Object(a.decodeEntities)(e.message),hidden:!1}}),receiveApplyingCoupon("")})},E=t=>{d(t).then(o=>{!0===o&&i("info",Object(n.sprintf)(
/* translators: %s coupon code. */
Object(n.__)('Coupon code "%s" has been removed from your cart.',"woocommerce"),t),{id:"coupon-form",type:"snackbar",context:e})}).catch(t=>{s(t.message,{id:"coupon-form",context:e}),receiveApplyingCoupon("")})};return{appliedCoupons:t,isLoading:o,applyCoupon:O,removeCoupon:E,isApplyingCoupon:b,isRemovingCoupon:m}}},333:function(e,t,o){"use strict";var n=o(12),r=o.n(n),c=o(0),a=o(1),l=o(8),s=o(4),i=o.n(s),u=o(11),p=o(30),d=o(6),b=o(3),m=o(19);o(294);var O=Object(l.forwardRef)((e,t)=>{let{className:o,id:n,type:a="text",ariaLabel:l,ariaDescribedBy:s,label:u,screenReaderLabel:p,disabled:d,help:b,autoCapitalize:O="off",autoComplete:E="off",value:g="",onChange:v,required:j=!1,onBlur:f=(()=>{}),feedback:_,...h}=e;const[w,C]=Object(c.useState)(!1);return Object(c.createElement)("div",{className:i()("wc-block-components-text-input",o,{"is-active":w||g})},Object(c.createElement)("input",r()({type:a,id:n,value:g,ref:t,autoCapitalize:O,autoComplete:E,onChange:e=>{v(e.target.value)},onFocus:()=>C(!0),onBlur:e=>{f(e.target.value),C(!1)},"aria-label":l||u,disabled:d,"aria-describedby":b&&!s?n+"__help":s,required:j},h)),Object(c.createElement)(m.a,{label:u,screenReaderLabel:p||u,wrapperElement:"label",wrapperProps:{htmlFor:n},htmlFor:n}),!!b&&Object(c.createElement)("p",{id:n+"__help",className:"wc-block-components-text-input__help"},b),_)}),E=o(291);t.a=Object(u.withInstanceId)(e=>{let{className:t,instanceId:o,id:n,ariaDescribedBy:s,errorId:u,focusOnMount:m=!1,onChange:g,showError:v=!0,errorMessage:j="",value:f="",..._}=e;const[h,w]=Object(l.useState)(!0),C=Object(l.useRef)(null),{setValidationErrors:y,hideValidationError:k,clearValidationError:I}=Object(d.dispatch)(b.VALIDATION_STORE_KEY),N=void 0!==n?n:"textinput-"+o,A=void 0!==u?u:N,{validationError:R,validationErrorId:S}=Object(d.useSelect)(e=>{const t=e(b.VALIDATION_STORE_KEY);return{validationError:t.getValidationError(A),validationErrorId:t.getValidationErrorId(A)}}),L=Object(l.useCallback)((function(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const t=C.current||null;if(!t)return;t.value=t.value.trim();const o=t.checkValidity();if(o)I(A);else{const o={[A]:{message:t.validationMessage||Object(a.__)("Invalid value.","woocommerce"),hidden:e}};y(o)}}),[I,A,y]);Object(l.useEffect)(()=>{var e;h&&m&&(null===(e=C.current)||void 0===e||e.focus()),w(!1)},[m,h,w]),Object(l.useEffect)(()=>{var e,t;(null===(e=C.current)||void 0===e||null===(t=e.ownerDocument)||void 0===t?void 0:t.activeElement)!==C.current&&L(!0)},[f,L]),Object(l.useEffect)(()=>()=>{I(A)},[I,A]),Object(p.a)(j)&&""!==j&&(R.message=j);const V=(null==R?void 0:R.message)&&!(null!=R&&R.hidden),T=v&&V&&S?S:s;return Object(c.createElement)(O,r()({className:i()(t,{"has-error":V}),"aria-invalid":!0===V,id:N,onBlur:()=>{L(!1)},feedback:v&&Object(c.createElement)(E.a,{errorMessage:j,propertyName:A}),ref:C,onChange:e=>{k(A),g(e)},ariaDescribedBy:T,value:f},_))})},355:function(e,t){},417:function(e,t,o){"use strict";var n=o(0),r=o(1),c=o(295),a=o(10),l=o(19),s=o(147),i=o(11),u=o(333),p=o(291),d=o(6),b=o(3);o(355),t.a=Object(i.withInstanceId)(e=>{let{instanceId:t,isLoading:o=!1,initialOpen:i=!1,onSubmit:m=(()=>{})}=e;const[O,E]=Object(n.useState)(""),g=Object(n.useRef)(!1),v="wc-block-components-totals-coupon__input-"+t,{validationError:j,validationErrorId:f}=Object(d.useSelect)(e=>{const t=e(b.VALIDATION_STORE_KEY);return{validationError:t.getValidationError("coupon"),validationErrorId:t.getValidationErrorId(v)}});return Object(n.useEffect)(()=>{g.current!==o&&(o||!O||j||E(""),g.current=o)},[o,O,j]),Object(n.createElement)(a.Panel,{className:"wc-block-components-totals-coupon",hasBorder:!1,initialOpen:i,title:Object(n.createElement)(l.a,{label:Object(r.__)("Coupon code","woocommerce"),screenReaderLabel:Object(r.__)("Apply a coupon code","woocommerce"),htmlFor:v})},Object(n.createElement)(s.a,{screenReaderLabel:Object(r.__)("Applying coupon…","woocommerce"),isLoading:o,showSpinner:!1},Object(n.createElement)("div",{className:"wc-block-components-totals-coupon__content"},Object(n.createElement)("form",{className:"wc-block-components-totals-coupon__form"},Object(n.createElement)(u.a,{id:v,errorId:"coupon",className:"wc-block-components-totals-coupon__input",label:Object(r.__)("Enter code","woocommerce"),value:O,ariaDescribedBy:f,onChange:e=>{E(e)},focusOnMount:!0,showError:!1}),Object(n.createElement)(c.a,{className:"wc-block-components-totals-coupon__button",disabled:o||!O,showSpinner:o,onClick:e=>{e.preventDefault(),m(O)},type:"submit"},Object(r.__)("Apply","woocommerce"))),Object(n.createElement)(p.b,{propertyName:"coupon",elementId:v}))))})},493:function(e,t,o){"use strict";o.r(t);var n=o(0),r=o(417),c=o(311),a=o(2),l=o(10);t.default=e=>{let{className:t}=e;const o=Object(a.getSetting)("couponsEnabled",!0),{applyCoupon:s,isApplyingCoupon:i}=Object(c.a)("wc/cart");return o?Object(n.createElement)(l.TotalsWrapper,{className:t},Object(n.createElement)(r.a,{onSubmit:s,isLoading:i})):null}}}]);