"use strict";(self.webpackChunkshopwp=self.webpackChunkshopwp||[]).push([["CartFooterDiscountWrapper-public"],{ylFW:function(e,t,n){n.r(t),n.d(t,{default:function(){return S}});var o=n("2MD/"),s=n("LpH3"),i=n("bNFS"),a=n("y+oc"),r=n("V+k2"),c=n("WZtd"),d=n("jAHd"),p=n.n(d),l={name:"1wlwxji-discountCodeIconCSS",styles:"position:absolute;right:11px;top:4px;max-width:9px;label:discountCodeIconCSS;"},u={name:"hx2du8-discountCodeCSS",styles:"font-size:15px;font-family:monospace;text-transform:uppercase;background:#ffd864;padding:3px 30px 3px 10px;position:relative;transition:background ease 0.2s;outline:2px dashed #d9833a;line-height:1.1;&:hover{cursor:pointer;background:#f1c952;};label:discountCodeCSS;"},f={name:"nsu3g3-discountLabelCSS",styles:"&&{flex:1;font-size:15px;position:relative;top:2px;margin-right:15px;};label:discountLabelCSS;"},b={name:"1vi8fpa-discountCodeWrapperCSS",styles:"display:flex;align-items:baseline;width:100%;justify-content:flex-start;margin-bottom:10px;border-bottom:1px solid #ddd;padding-bottom:12px;label:discountCodeWrapperCSS;"},C=function(e){var t=e.discountCode,n=e.changeDiscount,o=b,i=f,a=u,r=l;function d(){return(d=(0,c.Z)(p().mark((function e(){return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n("");case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}return(0,s.tZ)("div",{css:o},(0,s.tZ)("p",{css:i,className:"wps-cart-discount-label"},wp.i18n.__("Discount applied:","shopwp")),(0,s.tZ)("p",{className:"wps-cart-discount-code",css:a,onClick:function(){return d.apply(this,arguments)}},t,(0,s.tZ)("svg",{css:r,"aria-hidden":"true",focusable:"false","data-prefix":"far","data-icon":"times",className:"svg-inline--fa fa-times fa-w-10",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 320 512"},(0,s.tZ)("path",{fill:"currentColor",d:"M207.6 256l107.72-107.72c6.23-6.23 6.23-16.34 0-22.58l-25.03-25.03c-6.23-6.23-16.34-6.23-22.58 0L160 208.4 52.28 100.68c-6.23-6.23-16.34-6.23-22.58 0L4.68 125.7c-6.23 6.23-6.23 16.34 0 22.58L112.4 256 4.68 363.72c-6.23 6.23-6.23 16.34 0 22.58l25.03 25.03c6.23 6.23 16.34 6.23 22.58 0L160 303.6l107.72 107.72c6.23 6.23 16.34 6.23 22.58 0l25.03-25.03c6.23-6.23 6.23-16.34 0-22.58L207.6 256z"}))))},m=n("ZVgT"),x=wp.element.lazy((function(){return Promise.resolve().then(n.bind(n,"DGrm"))})),h={name:"1pg4opv-discountFormInputCSS",styles:"&&{appearance:none;background:transparent;flex:1;font-size:15px;padding:10px;margin-right:10px;border-radius:5px;border:1px solid #7e7e7e;outline:none;color:#121212;box-shadow:none;text-transform:uppercase;::placeholder,::-webkit-input-placeholder{text-transform:capitalize;color:#969696;}&:disabled{&:hover{cursor:not-allowed;}}};label:discountFormInputCSS;"},g={name:"14bfzb-discountFormCSS",styles:"display:flex;width:100%;margin-bottom:20px;label:discountFormCSS;"},w={name:"a930fn-discountCSS",styles:"display:flex;align-items:flex-end;justify-content:space-between;margin:0;label:discountCSS;"},S=function(){var e=wp.element,t=e.useRef,n=e.useState,c=e.useEffect,d=(0,m.Z)(),p=(0,a.K)(),l=(0,r.v)(),u=(0,r.h)(),f=(0,a.d)(),b=t(!1),S=n(p.discountCode),v=(0,o.Z)(S,2),y=v[0],k=v[1];c((function(){d.current&&k(p.discountCode?p.discountCode:"")}),[p.discountCode]);var Z=w,D=g,z=h,F=(0,s.iv)("width:100px;font-size:16px;border-radius:5px;border:1px solid #7e7e7e;appearance:none;color:black;background:white;padding:0;&:hover{cursor:",l.isCartUpdating?"not-allowed":"pointer",";color:rgba(0, 0, 0, 0.5);background:white;}&:focus{outline:none;}&:disabled{color:#c4c4c4;&:hover{cursor:not-allowed;}}.ball-pulse>div{background:black!important;width:8px!important;height:8px!important;};label:discountFormButtonCSS;");function L(e){p.isAddingDiscountCode||(0,i.R0)(f,l,e,u)}return(0,s.tZ)("div",{css:Z,className:"wps-discount-row"},p.discountCode?l.cartData.discountCodes.length?(0,s.tZ)(C,{discountCode:l.cartData.discountCodes[0].code,changeDiscount:L}):null:(0,s.tZ)("div",{css:D},(0,s.tZ)("input",{type:"text",placeholder:wp.i18n.__("Discount code","shopwp"),ref:b,css:z,disabled:l.isCartUpdating||p.isCartEmpty,onKeyDown:function(e){"Enter"===e.key&&L(b.current.value.toUpperCase())},onChange:function(e){k(e.target.value)},value:y}),(0,s.tZ)("button",{css:F,onClick:function(e){L(b.current.value.toUpperCase())},disabled:l.isCartUpdating||p.isCartEmpty||!y},!p.isAddingDiscountCode&&(0,s.tZ)("span",null,wp.i18n.__("Apply","shopwp")),p.isAddingDiscountCode&&(0,s.tZ)(x,null))))}}}]);