import{j as o,B as I}from"./index-7d3dbb9c.js";import{C as w}from"./index.esm-12cc9f7b.js";import{F as y}from"./FormControlLabel-4a3a4313.js";import{C as D}from"./Checkbox-4b8e4bb1.js";import{I as L,F as v}from"./InputLabel-ade41a0b.js";import{O as M}from"./OutlinedInput-e6d419ce.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:O="DD/MM/YYYY",disabled:f=!1,size:P="small",minDate:c,disableUppercase:g=!1,...n})=>o.jsx(w,{control:b,defaultValue:"",render:({field:t,fieldState:s})=>{var d,k,h;return o.jsxs(I,{sx:j,children:[e==="checkbox"?o.jsx(y,{control:o.jsx(D,{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(L,{sx:{".MuiInputLabel-asterisk":{color:"red"}},required:x,htmlFor:p??a,style:{fontWeight:"medium"},error:s.error!=null,children:m}),o.jsx(M,{size:"small",id:p??a,...t,...n,disabled:f,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",...!g&&{textTransform:"uppercase"},...((d=n.inputProps)==null?void 0:d.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)&&!g?r.target.value.toUpperCase():r.target.value;t.onChange(u),l&&l(r)}})]}),(i||((k=s.error)==null?void 0:k.message))&&o.jsx(v,{error:s.error!=null,children:((h=s.error)==null?void 0:h.message)??i})]})},name:a});export{T as F};
