Liferay.Loader.define("commerce-frontend-js@4.0.52/components/quantity_selector/InputQuantitySelector",["module","exports","require","@frontend-taglib-clay$clayui/form","@liferay/frontend-js-react-web","liferay!frontend-js-react-web$classnames","frontend-js-web","liferay!frontend-js-react-web$react","../../utilities/quantities","./RulesPopover"],(function(e,t,r){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=d(r("@frontend-taglib-clay$clayui/form")),a=r("@liferay/frontend-js-react-web"),u=f(r("liferay!frontend-js-react-web$classnames")),o=r("frontend-js-web"),l=d(r("liferay!frontend-js-react-web$react")),s=r("../../utilities/quantities"),i=f(r("./RulesPopover"));function f(e){return e&&e.__esModule?e:{default:e}}function c(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return c=function(){return e},e}function d(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=c();if(t&&t.has(e))return t.get(e);var r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if(Object.prototype.hasOwnProperty.call(e,a)){var u=n?Object.getOwnPropertyDescriptor(e,a):null;u&&(u.get||u.set)?Object.defineProperty(r,a,u):r[a]=e[a]}return r.default=e,t&&t.set(e,r),r}const e=(e,t,r,n)=>{const a=[];return(!e||e<t)&&a.push("min"),r&&e>r&&a.push("max"),n>1&&e%n&&a.push("multiple"),a},p=(0,l.forwardRef)((({alignment:t,className:r,disabled:f,max:c,min:d,name:m,onUpdate:p,quantity:y,step:b},j)=>{const[w,g]=(0,l.useState)(!1),[v,P]=(0,l.useState)((()=>e(y,d,c,b))),O=(0,a.useIsMounted)(),h=(0,l.useRef)((0,o.debounce)((e=>{O()&&P(e)}),500));(0,l.useEffect)((()=>{h.current((()=>e(y,d,c,b)))}),[y,d,c,b]);const x=(0,s.getProductMaxQuantity)(c,b),M=(0,s.getMinQuantity)(d,b);return l.default.createElement(n.default.Group,{className:(0,u.default)({"has-error":v.length,"mb-0":!0})},l.default.createElement(n.ClayInput,{className:r,disabled:f,max:x,min:M,name:m,onBlur:()=>{g(!1)},onChange:({target:t})=>{const r=Number(t.value),n=e(r,d,c,b);p({errors:n,value:r})},onFocus:()=>g(!0),ref:j,step:b>1?b:"",type:"number",value:String(y||"")}),w&&(b>1||d>1||v.includes("max"))&&l.default.createElement(i.default,{alignment:t,errors:v,inputRef:j,max:c||"",min:d,multiple:b}))}));p.defaultProps={max:null,min:1,step:1};var m=p;t.default=m}}));
//# sourceMappingURL=InputQuantitySelector.js.map