import{r as s}from"./index-BP8_t0zE.js";import{c as Y}from"./defaultI18nProvider-C_r1y4tu.js";import{u as Z,I as $,s as _}from"./SimpleForm-DxY-i_Qk.js";import{T as ee}from"./TextField-z9WrHgJg.js";import{F as re}from"./getFieldLabelTranslationArgs-DwcCC9dO.js";var i=function(){return i=Object.assign||function(e){for(var t,l=1,r=arguments.length;l<r;l++){t=arguments[l];for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a])}return e},i.apply(this,arguments)},S=function(e,t){var l={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(l[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,r=Object.getOwnPropertySymbols(e);a<r.length;a++)t.indexOf(r[a])<0&&Object.prototype.propertyIsEnumerable.call(e,r[a])&&(l[r[a]]=e[r[a]]);return l},se=function(e){var t=e.className,l=e.defaultValue,r=l===void 0?null:l,a=e.format,f=a===void 0?ae:a,y=e.helperText,j=e.label,C=e.margin,h=e.onChange,E=e.onBlur,N=e.onFocus,d=e.parse,O=e.resource,m=e.source,x=e.step,V=x===void 0?"any":x,w=e.min,A=e.max,q=e.validate,z=e.variant,H=e.inputProps,F=e.disabled,c=e.readOnly,T=S(e,["className","defaultValue","format","helperText","label","margin","onChange","onBlur","onFocus","parse","resource","source","step","min","max","validate","variant","inputProps","disabled","readOnly"]),p=Z(i({defaultValue:r,onBlur:E,resource:O,source:m,validate:q,disabled:F,readOnly:c},T)),o=p.field,P=p.fieldState,v=P.error,B=P.invalid,W=p.id,k=p.isRequired,I=o.onBlur,D=i(i({},H),{step:V,min:w,max:A}),R=s.useState(f(o.value)),G=R[0],b=R[1],g=s.useRef(!1);s.useEffect(function(){if(!g.current){var u=f(o.value);b(function(n){return n!==u?u:n})}},[o.value,f]);var J=function(u){if(h&&h(u),!(typeof u.target>"u"||typeof u.target.value>"u")){var n=u.target;b(n.value);var X=n.valueAsNumber!==void 0&&n.valueAsNumber!==null&&!isNaN(n.valueAsNumber)?d?d(n.valueAsNumber):n.valueAsNumber:d?d(n.value):ne(n.value);o.onChange(X)}},K=function(u){N&&N(u),g.current=!0},L=function(){I&&I(),g.current=!1;var u=f(o.value);b(function(n){return n!==u?u:n})},M=y!==!1||B,Q=o.ref,U=S(o,["ref"]);return s.createElement(ee,i({id:W},U,{inputRef:Q,value:G,onChange:J,onFocus:K,onBlur:L,className:Y("ra-input","ra-input-".concat(m),t),type:"number",size:"small",variant:z,error:B,disabled:F||c,readOnly:c,helperText:M?s.createElement($,{error:v==null?void 0:v.message,helperText:y}):null,label:s.createElement(re,{label:j,source:m,resource:O,isRequired:k}),margin:C,inputProps:i(i({},D),{readOnly:c})},_(T)))},ne=function(e){if(e==null||e==="")return null;var t=parseFloat(e);return isNaN(t)?0:t},ae=function(e){return e==null||isNaN(e)?"":e.toString()};export{se as N};
