import{j as o}from"./vendor-mui-69397583.js";import{r as i}from"./vendor-react-ece1c85f.js";import{b9 as P,d as k,bA as R}from"./index-c62ac197.js";const L=i.forwardRef((m,w)=>{const{checked:r,checkedContent:C,className:g,color:x,defaultChecked:a,disabled:n,isLoading:d=!1,labelRef:b,name:j,onChange:s,readOnly:h,unCheckedContent:y,field:l,...N}=m,{themeColor:v,primaryColorLevel:S}=P(),[t,f]=i.useState(a||r);i.useEffect(()=>{typeof r<"u"&&f(r)},[r]);const u=(()=>{let e=t,c={value:e};return l&&(e=typeof l.value=="boolean"?l.value:a,c={value:e,checked:e}),a&&(c.defaultChecked=a),c})(),$=e=>{const c=!t;n||h||d||(typeof r>"u"?(f(c),s==null||s(c,e)):s==null||s(t,e))},p=x||`${v}-${S}`,E=k("switcher",(t||u.checked)&&`switcher-checked bg-${p} dark:bg-${p}`,n&&"switcher-disabled",g);return o.jsxs("label",{ref:b,className:E,children:[o.jsx("input",{ref:w,type:"checkbox",disabled:n,readOnly:h,name:j,onChange:$,...u,...l,...N}),d?o.jsx(R,{className:k("switcher-toggle-loading",t?"switcher-checked-loading":"switcher-uncheck-loading")}):o.jsx("div",{className:"switcher-toggle"}),o.jsx("span",{className:"switcher-content",children:t?C:y})]})});L.displayName="Switcher";export{L as S};
