import{j as n}from"./query-vendor-CZu0EHPe.js";import{r as s}from"./react-vendor-0bvDbF03.js";import{a2 as O,a3 as A,a9 as B,P as w,a4 as R,a5 as H,a6 as K,N as j,C as L}from"./index-BazeBT21.js";import{u as q}from"./index-mXG3wuIW.js";var E="Checkbox",[z,W]=O(E),[T,X]=z(E),N=s.forwardRef((e,c)=>{const{__scopeCheckbox:t,name:d,checked:p,defaultChecked:r,required:h,disabled:i,value:m="on",onCheckedChange:C,form:u,...x}=e,[l,k]=s.useState(null),v=A(c,o=>k(o)),y=s.useRef(!1),P=l?u||!!l.closest("form"):!0,[f=!1,g]=B({prop:p,defaultProp:r,onChange:C}),M=s.useRef(f);return s.useEffect(()=>{const o=l?.form;if(o){const b=()=>g(M.current);return o.addEventListener("reset",b),()=>o.removeEventListener("reset",b)}},[l,g]),n.jsxs(T,{scope:t,state:f,disabled:i,children:[n.jsx(w.button,{type:"button",role:"checkbox","aria-checked":a(f)?"mixed":f,"aria-required":h,"data-state":_(f),"data-disabled":i?"":void 0,disabled:i,value:m,...x,ref:v,onKeyDown:R(e.onKeyDown,o=>{o.key==="Enter"&&o.preventDefault()}),onClick:R(e.onClick,o=>{g(b=>a(b)?!0:!b),P&&(y.current=o.isPropagationStopped(),y.current||o.stopPropagation())})}),P&&n.jsx(F,{control:l,bubbles:!y.current,name:d,value:m,checked:f,required:h,disabled:i,form:u,style:{transform:"translateX(-100%)"},defaultChecked:a(r)?!1:r})]})});N.displayName=E;var S="CheckboxIndicator",I=s.forwardRef((e,c)=>{const{__scopeCheckbox:t,forceMount:d,...p}=e,r=X(S,t);return n.jsx(H,{present:d||a(r.state)||r.state===!0,children:n.jsx(w.span,{"data-state":_(r.state),"data-disabled":r.disabled?"":void 0,...p,ref:c,style:{pointerEvents:"none",...e.style}})})});I.displayName=S;var F=e=>{const{control:c,checked:t,bubbles:d=!0,defaultChecked:p,...r}=e,h=s.useRef(null),i=q(t),m=K(c);s.useEffect(()=>{const u=h.current,x=window.HTMLInputElement.prototype,k=Object.getOwnPropertyDescriptor(x,"checked").set;if(i!==t&&k){const v=new Event("click",{bubbles:d});u.indeterminate=a(t),k.call(u,a(t)?!1:t),u.dispatchEvent(v)}},[i,t,d]);const C=s.useRef(a(t)?!1:t);return n.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:p??C.current,...r,tabIndex:-1,ref:h,style:{...e.style,...m,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function a(e){return e==="indeterminate"}function _(e){return a(e)?"indeterminate":e?"checked":"unchecked"}var D=N,$=I;const G=s.forwardRef(({className:e,...c},t)=>n.jsx(D,{ref:t,className:j("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",e),...c,children:n.jsx($,{className:j("flex items-center justify-center text-current"),children:n.jsx(L,{className:"h-4 w-4"})})}));G.displayName=D.displayName;export{G as C};
//# sourceMappingURL=checkbox-w6S3MlJ_.js.map