import{s as v}from"./chunk-DZLz74EQ.js";import{t as T}from"./react-BcIddLXZ.js";import{n as V,t as A}from"./jsx-runtime-DvsdsEjx.js";import{o as g}from"./useEventListener-C5BS4xuN.js";import{n as S,t as j}from"./cn-C5VTNYKf.js";import{m as B}from"./select-DJ0A_oCR.js";import{S as H,b as L,h as C,v as M}from"./Combination-DR4iFoRS.js";import{l as X}from"./dist-Cei_8ikW.js";var c=v(T(),1),u=v(A(),1),m="Switch",[F,de]=H(m),[G,J]=F(m),N=c.forwardRef((n,o)=>{let{__scopeSwitch:e,name:a,checked:t,defaultChecked:r,required:i,disabled:s,value:d="on",onCheckedChange:l,form:f,...k}=n,[p,w]=c.useState(null),q=g(o,b=>w(b)),x=c.useRef(!1),y=p?f||!!p.closest("form"):!0,[h,D]=M({prop:t,defaultProp:r??!1,onChange:l,caller:m});return(0,u.jsxs)(G,{scope:e,checked:h,disabled:s,children:[(0,u.jsx)(C.button,{type:"button",role:"switch","aria-checked":h,"aria-required":i,"data-state":R(h),"data-disabled":s?"":void 0,disabled:s,value:d,...k,ref:q,onClick:L(n.onClick,b=>{D(I=>!I),y&&(x.current=b.isPropagationStopped(),x.current||b.stopPropagation())})}),y&&(0,u.jsx)(E,{control:p,bubbles:!x.current,name:a,value:d,checked:h,required:i,disabled:s,form:f,style:{transform:"translateX(-100%)"}})]})});N.displayName=m;var _="SwitchThumb",z=c.forwardRef((n,o)=>{let{__scopeSwitch:e,...a}=n,t=J(_,e);return(0,u.jsx)(C.span,{"data-state":R(t.checked),"data-disabled":t.disabled?"":void 0,...a,ref:o})});z.displayName=_;var K="SwitchBubbleInput",E=c.forwardRef(({__scopeSwitch:n,control:o,checked:e,bubbles:a=!0,...t},r)=>{let i=c.useRef(null),s=g(i,r),d=B(e),l=X(o);return c.useEffect(()=>{let f=i.current;if(!f)return;let k=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(k,"checked").set;if(d!==e&&p){let w=new Event("click",{bubbles:a});p.call(f,e),f.dispatchEvent(w)}},[d,e,a]),(0,u.jsx)("input",{type:"checkbox","aria-hidden":!0,defaultChecked:e,...t,tabIndex:-1,ref:s,style:{...t.style,...l,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});E.displayName=K;function R(n){return n?"checked":"unchecked"}var O=N,Q=z,U=v(V(),1),W=S("peer inline-flex shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",{variants:{size:{default:"h-6 w-11 mb-1",sm:"h-4.5 w-8.5",xs:"h-4 w-7"}},defaultVariants:{size:"default"}}),Y=S("pointer-events-none block rounded-full bg-background shadow-xs ring-0 transition-transform",{variants:{size:{default:"h-5 w-5 data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0",sm:"h-3.5 w-3.5 data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0",xs:"h-3 w-3 data-[state=checked]:translate-x-3 data-[state=unchecked]:translate-x-0"}},defaultVariants:{size:"default"}}),P=c.forwardRef((n,o)=>{let e=(0,U.c)(16),a,t,r;e[0]===n?(a=e[1],t=e[2],r=e[3]):({className:a,size:r,...t}=n,e[0]=n,e[1]=a,e[2]=t,e[3]=r);let i;e[4]!==a||e[5]!==r?(i=j(W({size:r}),a),e[4]=a,e[5]=r,e[6]=i):i=e[6];let s;e[7]===r?s=e[8]:(s=j(Y({size:r})),e[7]=r,e[8]=s);let d;e[9]===s?d=e[10]:(d=(0,u.jsx)(Q,{className:s}),e[9]=s,e[10]=d);let l;return e[11]!==t||e[12]!==o||e[13]!==i||e[14]!==d?(l=(0,u.jsx)(O,{className:i,...t,ref:o,children:d}),e[11]=t,e[12]=o,e[13]=i,e[14]=d,e[15]=l):l=e[15],l});P.displayName=O.displayName;export{P as t};
