import{r as n}from"./vendor-react-DX7tU9aY.js";import{j as z,b8 as M,X as h}from"./vendor-mui-core-CDEc-eG6.js";import{b as C}from"./vendor-hooks-Ca2cSNuD.js";import{bj as W}from"./vendor-ux-PO0jFgJf.js";const w=(i,a=10,s=500)=>{if(typeof document>"u")return 0;const o=document.createElement("canvas").getContext("2d");return o.font=`${s} ${a}px sans-serif`,o.measureText(i).width};function E({checked:i,onChange:a,width:s=0}){const{t:e}=n.useContext(W),[o,c]=n.useState(!1),x=C(t=>{c(t.target.checked),a(t.target.checked)});n.useEffect(()=>{c(i)},[i]);const l=n.useMemo(()=>e(`webhookEndpoint.${o?"enabled":"disabled"}`),[o,e]),k=n.useMemo(()=>{const t=e("webhookEndpoint.enabled"),p=e("webhookEndpoint.disabled"),m=w(t,10,500),b=w(p,10,500),r=Math.max(m,b),S=18+3+r+6;return Math.max(Math.ceil(S/2)*2,50)},[e]),u=s||k;return z.jsx(M,{checked:o,onChange:x,sx:t=>{const r=u-18-6,d=t.palette.mode==="dark",g=t.palette.common[d?"black":"white"],f=t.palette.common[d?"white":"black"];return{width:u,height:24,padding:0,"& .MuiSwitch-switchBase":{padding:0,margin:"3px",transitionDuration:"300ms","&.Mui-checked":{transform:`translateX(${r}px)`,color:t.palette.common.white,"& + .MuiSwitch-track":{backgroundColor:t.palette.primary.main,opacity:1,border:0,"&:before":{content:`"${l}"`,position:"absolute",left:t.spacing(.75),top:"50%",transform:"translateY(-50%)",color:g,fontSize:10,fontWeight:500}}}},"& .MuiSwitch-thumb":{width:18,height:18},"& .MuiSwitch-track":{borderRadius:24/2,backgroundColor:t.palette.grey[200],opacity:1,position:"relative","&:before":{content:`"${l}"`,position:"absolute",right:t.spacing(.75),top:"50%",transform:"translateY(-50%)",color:f,fontSize:10,fontWeight:500}}}}})}E.propTypes={checked:h.bool.isRequired,onChange:h.func.isRequired,width:h.number};export{E as S};
