import{cF as Q,cG as V,f as k,c$ as W,cS as X,r as Y,cK as C,j as b,cH as Z,cM as _}from"./index-55b8aeb0.js";import{u as ee}from"./useFormControl-0fae9ee7.js";import{u as oe}from"./useControlled-dc1d5a3a.js";function te(t){return Q("PrivateSwitchBase",t)}V("PrivateSwitchBase",["root","checked","disabled","input","edgeStart","edgeEnd"]);const se=t=>{const{classes:s,checked:l,disabled:d,edge:i}=t,u={root:["root",l&&"checked",d&&"disabled",i&&`edge${Z(i)}`],input:["input"]};return _(u,te,s)},ne=k(W)({padding:9,borderRadius:"50%",variants:[{props:{edge:"start",size:"small"},style:{marginLeft:-3}},{props:({edge:t,ownerState:s})=>t==="start"&&s.size!=="small",style:{marginLeft:-12}},{props:{edge:"end",size:"small"},style:{marginRight:-3}},{props:({edge:t,ownerState:s})=>t==="end"&&s.size!=="small",style:{marginRight:-12}}]}),ae=k("input",{shouldForwardProp:X})({cursor:"inherit",position:"absolute",opacity:0,width:"100%",height:"100%",top:0,left:0,margin:0,padding:0,zIndex:1}),ie=Y.forwardRef(function(s,l){const{autoFocus:d,checked:i,checkedIcon:u,defaultChecked:f,disabled:y,disableFocusRipple:h=!1,edge:x=!1,icon:R,id:I,inputProps:z,inputRef:j,name:E,onBlur:m,onChange:g,onFocus:S,readOnly:U,required:L=!1,tabIndex:$,type:r,value:P,slots:N={},slotProps:T={},...q}=s,[w,G]=oe({controlled:i,default:!!f,name:"SwitchBase",state:"checked"}),n=ee(),H=e=>{S&&S(e),n&&n.onFocus&&n.onFocus(e)},K=e=>{m&&m(e),n&&n.onBlur&&n.onBlur(e)},M=e=>{if(e.nativeEvent.defaultPrevented)return;const o=e.target.checked;G(o),g&&g(e,o)};let c=y;n&&typeof c>"u"&&(c=n.disabled);const O=r==="checkbox"||r==="radio",p={...s,checked:w,disabled:c,disableFocusRipple:h,edge:x},B=se(p),F={slots:N,slotProps:{input:z,...T}},[v,A]=C("root",{ref:l,elementType:ne,className:B.root,shouldForwardComponentProp:!0,externalForwardedProps:{...F,component:"span",...q},getSlotProps:e=>({...e,onFocus:o=>{var a;(a=e.onFocus)==null||a.call(e,o),H(o)},onBlur:o=>{var a;(a=e.onBlur)==null||a.call(e,o),K(o)}}),ownerState:p,additionalProps:{centerRipple:!0,focusRipple:!h,disabled:c,role:void 0,tabIndex:null}}),[D,J]=C("input",{ref:j,elementType:ae,className:B.input,externalForwardedProps:F,getSlotProps:e=>({...e,onChange:o=>{var a;(a=e.onChange)==null||a.call(e,o),M(o)}}),ownerState:p,additionalProps:{autoFocus:d,checked:i,defaultChecked:f,disabled:c,id:O?I:void 0,name:E,readOnly:U,required:L,tabIndex:$,type:r,...r==="checkbox"&&P===void 0?{}:{value:P}}});return b.jsxs(v,{...A,children:[b.jsx(D,{...J}),w?u:R]})}),de=ie;export{de as S};
