import*as e from"react";import{useCheckboxGroupContext as s}from"./checkbox-group.js";import{CheckboxIcon as t}from"./checkbox-icon.js";import{useCheckbox as i}from"./use-checkbox.js";import{omitThemingProps as n}from"../../../system/dist/esm/system.utils.js";import{callAll as r}from"../../../utils/dist/esm/function.js";import{chakra as o}from"../../../system/dist/esm/system.js";import{forwardRef as a}from"../../../system/dist/esm/forward-ref.js";import{useMultiStyleConfig as c}from"../../../system/dist/esm/use-style-config.js";import{cx as l}from"../../../utils/dist/esm/dom.js";import{__DEV__ as m}from"../../../utils/dist/esm/assertion.js";function d(){return(d=Object.assign||function(e){for(var s=1;s<arguments.length;s++){var t=arguments[s];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e}).apply(this,arguments)}var p=o("span",{baseStyle:{display:"inline-flex",alignItems:"center",justifyContent:"center",verticalAlign:"top",userSelect:"none",flexShrink:0}}),u=o("label",{baseStyle:{cursor:"pointer",display:"inline-flex",alignItems:"center",verticalAlign:"top",position:"relative",_disabled:{cursor:"not-allowed"}}}),h=a(((a,m)=>{var h=s(),f=d({},h,a),b=c("Checkbox",f),k=n(a),{spacing:g="0.5rem",className:C,children:y,iconColor:v,iconSize:x,icon:_=e.createElement(t,null),isChecked:j,isDisabled:I=(null==h?void 0:h.isDisabled),onChange:S}=k,N=function(e,s){if(null==e)return{};var t,i,n={},r=Object.keys(e);for(i=0;i<r.length;i++)t=r[i],s.indexOf(t)>=0||(n[t]=e[t]);return n}(k,["spacing","className","children","iconColor","iconSize","icon","isChecked","isDisabled","onChange"]),E=j;null!=h&&h.value&&k.value&&(E=h.value.includes(k.value));var O=S;null!=h&&h.onChange&&k.value&&(O=r(h.onChange,S));var{state:P,getInputProps:D,getCheckboxProps:w,getLabelProps:z,getRootProps:A}=i(d({},N,{isDisabled:I,isChecked:E,onChange:O})),L=e.useMemo((()=>d({opacity:P.isChecked||P.isIndeterminate?1:0,transform:P.isChecked||P.isIndeterminate?"scale(1)":"scale(0.95)",fontSize:x,color:v},b.icon)),[v,x,P.isChecked,P.isIndeterminate,b.icon]),M=e.cloneElement(_,{__css:L,isIndeterminate:P.isIndeterminate,isChecked:P.isChecked});return e.createElement(u,d({__css:b.container,className:l("chakra-checkbox",C)},A()),e.createElement("input",d({className:"chakra-checkbox__input"},D({},m))),e.createElement(p,d({__css:b.control,className:"chakra-checkbox__control"},w()),M),y&&e.createElement(o.span,d({className:"chakra-checkbox__label"},z(),{__css:d({marginStart:g},b.label)}),y))}));m&&(h.displayName="Checkbox");export{h as Checkbox};
//# sourceMappingURL=checkbox.js.map
