var O=Object.defineProperty,D=Object.defineProperties;var F=Object.getOwnPropertyDescriptors;var S=Object.getOwnPropertySymbols;var N=Object.prototype.hasOwnProperty,j=Object.prototype.propertyIsEnumerable;var E=(e,t,r)=>t in e?O(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,u=(e,t)=>{for(var r in t||(t={}))N.call(t,r)&&E(e,r,t[r]);if(S)for(var r of S(t))j.call(t,r)&&E(e,r,t[r]);return e},p=(e,t)=>D(e,F(t));var b=(e,t)=>{var r={};for(var s in e)N.call(e,s)&&t.indexOf(s)<0&&(r[s]=e[s]);if(e!=null&&S)for(var s of S(e))t.indexOf(s)<0&&j.call(e,s)&&(r[s]=e[s]);return r};import{r as n,a5 as B,x as J,j as d,y as W,P as T,J as X,av as $,c as _}from"./index-C7Y5J1TO.js";function G(e){const t=n.useRef({value:e,previous:e});return n.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var x="Switch",[K,se]=W(x),[Q,V]=K(x),I=n.forwardRef((e,t)=>{const R=e,{__scopeSwitch:r,name:s,checked:o,defaultChecked:a,required:g,disabled:c,value:f="on",onCheckedChange:k,form:h}=R,y=b(R,["__scopeSwitch","name","checked","defaultChecked","required","disabled","value","onCheckedChange","form"]),[i,C]=n.useState(null),P=B(t,w=>C(w)),l=n.useRef(!1),m=i?h||!!i.closest("form"):!0,[v,z]=J({prop:o,defaultProp:a!=null?a:!1,onChange:k,caller:x});return d.jsxs(Q,{scope:r,checked:v,disabled:c,children:[d.jsx(T.button,p(u({type:"button",role:"switch","aria-checked":v,"aria-required":g,"data-state":U(v),"data-disabled":c?"":void 0,disabled:c,value:f},y),{ref:P,onClick:X(e.onClick,w=>{z(L=>!L),m&&(l.current=w.isPropagationStopped(),l.current||w.stopPropagation())})})),m&&d.jsx(A,{control:i,bubbles:!l.current,name:s,value:f,checked:v,required:g,disabled:c,form:h,style:{transform:"translateX(-100%)"}})]})});I.displayName=x;var M="SwitchThumb",H=n.forwardRef((e,t)=>{const a=e,{__scopeSwitch:r}=a,s=b(a,["__scopeSwitch"]),o=V(M,r);return d.jsx(T.span,p(u({"data-state":U(o.checked),"data-disabled":o.disabled?"":void 0},s),{ref:t}))});H.displayName=M;var Y="SwitchBubbleInput",A=n.forwardRef((g,a)=>{var c=g,{__scopeSwitch:e,control:t,checked:r,bubbles:s=!0}=c,o=b(c,["__scopeSwitch","control","checked","bubbles"]);const f=n.useRef(null),k=B(f,a),h=G(r),y=$(t);return n.useEffect(()=>{const i=f.current;if(!i)return;const C=window.HTMLInputElement.prototype,l=Object.getOwnPropertyDescriptor(C,"checked").set;if(h!==r&&l){const m=new Event("click",{bubbles:s});l.call(i,r),i.dispatchEvent(m)}},[h,r,s]),d.jsx("input",p(u({type:"checkbox","aria-hidden":!0,defaultChecked:r},o),{tabIndex:-1,ref:k,style:p(u(u({},o.style),y),{position:"absolute",pointerEvents:"none",opacity:0,margin:0})}))});A.displayName=Y;function U(e){return e?"checked":"unchecked"}var q=I,Z=H;const ee=n.forwardRef((s,r)=>{var o=s,{className:e}=o,t=b(o,["className"]);return d.jsx(q,p(u({className:_("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e)},t),{ref:r,children:d.jsx(Z,{className:_("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})}))});ee.displayName=q.displayName;export{ee as S,G as u};
