import{j as o,B as f}from"./index-c1429e77.js";import{C as I}from"./index.esm-e372dd1f.js";import{F as w}from"./FormControlLabel-9a892c17.js";import{C as y}from"./Checkbox-46376d3a.js";import{I as D,F as L}from"./InputLabel-e729048c.js";import{O as v}from"./OutlinedInput-7d44f8dd.js";const T=({control:b,id:p,label:m,name:a,helperText:i,containerSx:j,minlength:C,maxlength:F,onChange:l,required:x,type:e,format:M="DD/MM/YYYY",disabled:O=!1,size:P="small",minDate:c,disableUppercase:d=!1,...n})=>o.jsx(I,{control:b,defaultValue:"",render:({field:t,fieldState:s})=>{var g,k,h;return o.jsxs(f,{sx:j,children:[e==="checkbox"?o.jsx(w,{control:o.jsx(y,{id:p??a,...t,required:x,checked:!!t.value,onChange:r=>{t.onChange(r.target.checked),l&&l(r)}}),label:m}):o.jsxs(o.Fragment,{children:[o.jsx(D,{sx:{".MuiInputLabel-asterisk":{color:"red"}},required:x,htmlFor:p??a,style:{fontWeight:"medium"},error:s.error!=null,children:m}),o.jsx(v,{size:"small",id:p??a,...t,...n,type:e==="number"?"text":e,sx:r=>({width:"100%",mt:1,backgroundColor:r.palette.background.paper,"&.Mui-disabled":{borderColor:s.error?"red":"#e6e6e6fd","& .MuiOutlinedInput-notchedOutline":{borderColor:s.error?"red":"inherit"}}}),error:s.error!=null,inputProps:{minLength:C,maxLength:F,...e==="date"&&c?{min:c.toISOString().split("T")[0]}:{},style:{padding:"10px 12px",...!d&&{textTransform:"uppercase"},...((g=n.inputProps)==null?void 0:g.style)||{}},...n.inputProps,...e==="number"?{onKeyDown:r=>{var u;!/[0-9.-]/.test(r.key)&&r.key!=="Backspace"&&r.key!=="Delete"&&r.key!=="ArrowLeft"&&r.key!=="ArrowRight"&&r.preventDefault(),(u=n.inputProps)!=null&&u.onKeyDown&&n.inputProps.onKeyDown(r)}}:{}},onChange:r=>{const u=(e==="text"||!e)&&!d?r.target.value.toUpperCase():r.target.value;t.onChange(u),l&&l(r)}})]}),(i||((k=s.error)==null?void 0:k.message))&&o.jsx(L,{error:s.error!=null,children:((h=s.error)==null?void 0:h.message)??i})]})},name:a});export{T as F};
