import{c as e}from"./security-CTzQb9Ko.js";import{$i as t,Qi as n,s as r}from"./bundle-mjs-lcbR1pPJ.js";import{a as i,c as a,f as o,l as s,m as c,s as l,u}from"./dist-C0UdmnhX.js";var d=e(t(),1),f=e(n(),1),p=`Checkbox`,[m,h]=c(p),[g,_]=m(p);function v(e){let{__scopeCheckbox:t,checked:n,children:r,defaultChecked:i,disabled:a,form:o,name:s,onCheckedChange:c,required:l,value:m=`on`,internal_do_not_use_render:h}=e,[_,v]=u({prop:n,defaultProp:i??!1,onChange:c,caller:p}),[y,b]=d.useState(null),[x,S]=d.useState(null),C=d.useRef(!1),w=y?!!o||!!y.closest(`form`):!0,T={checked:_,disabled:a,setChecked:v,control:y,setControl:b,name:s,form:o,value:m,hasConsumerStoppedPropagationRef:C,required:l,defaultChecked:D(i)?!1:i,isFormControl:w,bubbleInput:x,setBubbleInput:S};return(0,f.jsx)(g,{scope:t,...T,children:E(h)?h(T):r})}var y=`CheckboxTrigger`,b=d.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...a},s)=>{let{control:c,value:l,disabled:u,checked:p,required:m,setControl:h,setChecked:g,hasConsumerStoppedPropagationRef:v,isFormControl:b,bubbleInput:x}=_(y,e),S=r(s,h),C=d.useRef(p);return d.useEffect(()=>{let e=c?.form;if(e){let t=()=>g(C.current);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[c,g]),(0,f.jsx)(i.button,{type:`button`,role:`checkbox`,"aria-checked":D(p)?`mixed`:p,"aria-required":m,"data-state":O(p),"data-disabled":u?``:void 0,disabled:u,value:l,...a,ref:S,onKeyDown:o(t,e=>{e.key===`Enter`&&e.preventDefault()}),onClick:o(n,e=>{g(e=>D(e)?!0:!e),x&&b&&(v.current=e.isPropagationStopped(),v.current||e.stopPropagation())})})});b.displayName=y;var x=d.forwardRef((e,t)=>{let{__scopeCheckbox:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c,onCheckedChange:l,form:u,...d}=e;return(0,f.jsx)(v,{__scopeCheckbox:n,checked:i,defaultChecked:a,disabled:s,required:o,onCheckedChange:l,name:r,form:u,value:c,internal_do_not_use_render:({isFormControl:e})=>(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(b,{...d,ref:t,__scopeCheckbox:n}),e&&(0,f.jsx)(T,{__scopeCheckbox:n})]})})});x.displayName=p;var S=`CheckboxIndicator`,C=d.forwardRef((e,t)=>{let{__scopeCheckbox:n,forceMount:r,...a}=e,o=_(S,n);return(0,f.jsx)(l,{present:r||D(o.checked)||o.checked===!0,children:(0,f.jsx)(i.span,{"data-state":O(o.checked),"data-disabled":o.disabled?``:void 0,...a,ref:t,style:{pointerEvents:`none`,...e.style}})})});C.displayName=S;var w=`CheckboxBubbleInput`,T=d.forwardRef(({__scopeCheckbox:e,...t},n)=>{let{control:o,hasConsumerStoppedPropagationRef:c,checked:l,defaultChecked:u,required:p,disabled:m,name:h,value:g,form:v,bubbleInput:y,setBubbleInput:b}=_(w,e),x=r(n,b),S=s(l),C=a(o);d.useEffect(()=>{let e=y;if(!e)return;let t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,`checked`).set,r=!c.current;if(S!==l&&n){let t=new Event(`click`,{bubbles:r});e.indeterminate=D(l),n.call(e,D(l)?!1:l),e.dispatchEvent(t)}},[y,S,l,c]);let T=d.useRef(D(l)?!1:l);return(0,f.jsx)(i.input,{type:`checkbox`,"aria-hidden":!0,defaultChecked:u??T.current,required:p,disabled:m,name:h,value:g,form:v,...t,tabIndex:-1,ref:x,style:{...t.style,...C,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0,transform:`translateX(-100%)`}})});T.displayName=w;function E(e){return typeof e==`function`}function D(e){return e===`indeterminate`}function O(e){return D(e)?`indeterminate`:e?`checked`:`unchecked`}export{C as n,x as t};