import{j as o,B as w}from"./index-d2b25495.js";import{C as F}from"./index.esm-ce3c2c20.js";import{F as v}from"./FormControlLabel-78be0abe.js";import{C as I}from"./Checkbox-d1c5682c.js";import{I as m,F as L}from"./InputLabel-bb6ab40e.js";import{O as h}from"./OutlinedInput-86f3ec98.js";const E=({control:g,id:u,label:l,name:n,helperText:c,containerSx:k,minlength:b,maxlength:j,capitalize:C,onChange:s,required:a,type:p,...i})=>o.jsx(F,{control:g,defaultValue:"",render:({field:t,fieldState:e})=>{var d,x;return o.jsxs(w,{sx:k,children:[p==="checkbox"?o.jsx(v,{control:o.jsx(I,{id:u??n,...t,required:a,checked:!!t.value,onChange:r=>{t.onChange(r.target.checked),s&&s(r)}}),label:l}):p==="number"?o.jsxs(o.Fragment,{children:[o.jsx(m,{sx:{".MuiInputLabel-asterisk":{color:"red"}},required:a,htmlFor:u??n,style:{fontWeight:"medium"},error:e.error!=null,children:l}),o.jsx(h,{id:u??n,...i,...t,type:"text",sx:r=>({width:"100%",mt:1,backgroundColor:r.palette.background.paper,"&.Mui-disabled":{borderColor:e.error?"red":"#e6e6e6fd","& .MuiOutlinedInput-notchedOutline":{borderColor:e.error?"red":"inherit"}}}),error:e.error!=null,inputProps:{minLength:b,maxLength:j,style:{padding:"10px 12px"},onKeyDown:r=>{if((r.ctrlKey||r.metaKey)&&["c","v","x","a","z","y"].includes(r.key.toLowerCase()))return;const y=["Backspace","Delete","Tab","Escape","Enter","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End",".","-"];!/[\d]/.test(r.key)&&!y.includes(r.key)&&r.preventDefault(),r.key==="."&&r.target.value.includes(".")&&r.preventDefault(),r.key==="-"&&r.target.selectionStart!==0&&r.preventDefault()}},onChange:r=>{t.onChange(r.target.value),s&&s(r)}})]}):o.jsxs(o.Fragment,{children:[l&&o.jsx(m,{sx:{".MuiInputLabel-asterisk":{color:"red"}},required:a,htmlFor:u??n,style:{fontWeight:"medium"},error:e.error!=null,children:l}),o.jsx(h,{id:u??n,...i,...t,type:p,sx:r=>({width:"100%",mt:1,backgroundColor:r.palette.background.paper,"&.Mui-disabled":{borderColor:e.error?"red":"#e6e6e6fd","& .MuiOutlinedInput-notchedOutline":{borderColor:e.error?"red":"inherit"}}}),error:e.error!=null,inputProps:{style:{padding:"10px 12px",...C&&{textTransform:"uppercase"}}},onChange:r=>{t.onChange(r.target.value),s&&s(r)}})]}),(c||((d=e.error)==null?void 0:d.message))&&o.jsx(L,{error:e.error!=null,children:((x=e.error)==null?void 0:x.message)??c})]})},name:n});export{E as F};
