import{r as t}from"./index-NdkWRN8K.js";import{K,u as U}from"./OdysseyThemeProvider-Bh0Bu-2o.js";import{g as W,C as w}from"./inputUtils-Dbi8XkA6.js";import{M as g}from"./Typography-Cz6D417Y.js";import{u as A}from"./useUniqueId-Bsgqe1tm.js";import{H as B}from"./Hint-DoJneNg9.js";import{j as e}from"./jsx-runtime-CnH95YSl.js";import{F as G}from"./FormControlLabel-0BBemR80.js";import{C as J}from"./Checkbox-vZwuXtzm.js";import{F as Q}from"./FormHelperText-CsNAE1E3.js";const ne=["valid","invalid","inherit"],X=({ariaLabel:y,ariaLabelledBy:C,id:c,inputRef:M,isChecked:i,isDefaultChecked:m,isDisabled:d,isIndeterminate:j,isReadOnly:s=!1,isRequired:n,label:p,hint:a,name:S,onChange:r,onBlur:l,testId:x,translate:f,validity:b="inherit",value:T})=>{const{t:k}=K(),F=U(),I=A(c),u=a?`${I}-hint`:void 0,V=t.useRef(W({controlledValue:i,uncontrolledValue:m})),v=t.useMemo(()=>V.current===w.CONTROLLED?{checked:i}:{defaultChecked:m},[m,i]),h=t.useRef(null);t.useImperativeHandle(M,()=>({focus:()=>{var o;(o=h.current)==null||o.focus()}}),[]);const E=t.useMemo(()=>e.jsxs(e.Fragment,{children:[e.jsx(g,{component:"span",children:p}),n&&e.jsxs(e.Fragment,{children:[" ",e.jsxs(g,{color:"textSecondary",component:"span",children:["(",k("fieldlabel.required.text"),")"]})]})]}),[n,p,k]),H=t.useCallback((o,q)=>{r==null||r(o,q)},[r]),L=t.useCallback(o=>{s&&(o.stopPropagation(),o.preventDefault())},[s]),N=t.useCallback(o=>{l==null||l(o)},[l]),z=t.useMemo(()=>({alignItems:"flex-start",...s&&{cursor:"default","& .MuiTypography-root":{cursor:"default"}},...a&&{":not(:last-child)":{marginBlockEnd:"0"}}}),[a,s]),D=t.useMemo(()=>({marginBlockStart:"2px"}),[]),$=t.useMemo(()=>({"aria-describedby":u,"aria-readonly":s,"data-se":x,readOnly:s}),[u,s,x]);return e.jsxs(e.Fragment,{children:[e.jsx(G,{"aria-label":y,"aria-labelledby":C,className:b==="invalid"?"Mui-error":b==="valid"?"Mui-valid":"",control:e.jsx(J,{...v,disabled:d,indeterminate:j,inputProps:$,inputRef:h,onChange:H,onClick:L,required:n,sx:D}),disabled:d,id:c,label:E,name:S??c,onBlur:N,required:n,sx:z,translate:f,value:T}),a&&e.jsx(B,{odysseyDesignTokens:F,children:e.jsx(Q,{id:u,translate:f,children:a})})]})},Y=t.memo(X);Y.displayName="Checkbox";export{Y as M,ne as c};
