import{bl as x,aD as O,a5 as f,a4 as R,c4 as E,c5 as I,r as U}from"./index-BX768Frx.js";function w(e,a,l){let{isDisabled:d=!1,isReadOnly:s=!1,value:r,name:o,form:i,children:b,"aria-label":V,"aria-labelledby":j,validationState:u="valid",isInvalid:$,onPressStart:S,onPressEnd:v,onPressChange:P,onPress:c,onPressUp:g,onClick:p}=e,m=t=>{t.stopPropagation(),a.setSelected(t.target.checked)},{pressProps:y,isPressed:h}=x({onPressStart:S,onPressEnd:v,onPressChange:P,onPress:c,onPressUp:g,onClick:p,isDisabled:d}),{pressProps:C,isPressed:k}=x({onPressStart:S,onPressEnd:v,onPressChange:P,onPressUp:g,onClick:p,onPress(t){var n;c?.(t),a.toggle(),(n=l.current)===null||n===void 0||n.focus()},isDisabled:d||s}),{focusableProps:D}=O(e,l),_=f(y,D),L=R(e,{labelable:!0});return E(l,a.defaultSelected,a.setSelected),{labelProps:f(C,{onClick:t=>t.preventDefault()}),inputProps:f(L,{"aria-invalid":$||u==="invalid"||void 0,"aria-errormessage":e["aria-errormessage"],"aria-controls":e["aria-controls"],"aria-readonly":s||void 0,onChange:m,disabled:d,...r==null?{}:{value:r},name:o,form:i,type:"checkbox",..._}),isSelected:a.isSelected,isPressed:h||k,isDisabled:d,isReadOnly:s,isInvalid:$||u==="invalid"}}function z(e={}){let{isReadOnly:a}=e,[l,d]=I(e.isSelected,e.defaultSelected||!1,e.onChange),[s]=U.useState(l);function r(b){a||d(b)}function o(){a||d(!l)}var i;return{isSelected:l,defaultSelected:(i=e.defaultSelected)!==null&&i!==void 0?i:s,setSelected:r,toggle:o}}export{w as $,z as a};
