import{o as e}from"./chunk.DuxOD-Sk.js";import{r as t}from"./emotion-is-prop-valid.esm.DV_OErv-.js";import{c as n,l as r}from"./emotion-styled.browser.esm.BPUx6WuE.js";import{f as i}from"./getColors.DUygtxH4.js";import{c as a}from"./protobuf.DyZGXwGk.js";import{St as o,nt as s,rt as c,wt as l,z as u}from"./src.sR_9Xh2m.js";import{t as d}from"./useEmotionTheme.61kSPILX.js";import{N as f}from"./utils.B9mvrYZE.js";import{n as p,r as m,t as h}from"./checkbox.D-sGpr_4.js";import{n as g}from"./useBasicWidgetState.DAZ7WsXN.js";var _=e(t());function v({element:e,disabled:t,widgetMgr:v,fragmentId:C}){let[w,T]=g({getStateFromWidgetMgr:y,getDefaultStateFromProto:b,getCurrStateFromProto:x,updateWidgetMgrState:S,element:e,widgetMgr:v,fragmentId:C,formClearBehavior:`resetValueOnly`,queryParamBinding:e.queryParamKey?{paramKey:e.queryParamKey,valueType:`bool_value`,clearable:!1}:void 0}),E=(0,_.useCallback)(e=>{T({value:e.target.checked,fromUi:!0})},[T]),D=d(),{colors:O,spacing:k,sizes:A}=D,j=i(D),M=t?O.fadedText40:O.bodyText;return n(s,{className:`row-widget stCheckbox`,"data-testid":`stCheckbox`,children:n(h,{checked:w,disabled:t,onChange:E,"aria-label":e.label,checkmarkType:e.type===a.StyleType.TOGGLE?m.toggle:m.default,labelPlacement:p.right,overrides:{Root:{style:({$isFocusVisible:e})=>({marginBottom:k.none,marginTop:k.none,backgroundColor:e?O.darkenedBgMix25:``,display:`flex`,alignItems:`start`})},Toggle:{style:({$checked:e})=>{let n=j?O.bgColor:O.bodyText;return t&&(n=j?O.gray70:O.gray90),{width:`calc(${A.checkbox} - ${D.spacing.twoXS})`,height:`calc(${A.checkbox} - ${D.spacing.twoXS})`,transform:e?`translateX(${A.checkbox})`:``,backgroundColor:n,boxShadow:``}}},ToggleTrack:{style:({$checked:e,$isHovered:n})=>{let r=O.borderColor;return n&&!t&&(r=O.darkenedBgMix15),e&&!t&&(r=O.primary),{marginRight:0,marginLeft:0,marginBottom:0,marginTop:D.spacing.twoXS,paddingLeft:D.spacing.threeXS,paddingRight:D.spacing.threeXS,width:`calc(2 * ${A.checkbox})`,minWidth:`calc(2 * ${A.checkbox})`,height:A.checkbox,minHeight:A.checkbox,borderBottomLeftRadius:D.radii.full,borderTopLeftRadius:D.radii.full,borderBottomRightRadius:D.radii.full,borderTopRightRadius:D.radii.full,backgroundColor:r}}},Checkmark:{style:({$isFocusVisible:e,$checked:n})=>{let r=n&&!t?O.primary:O.borderColor;return{outline:0,width:A.checkbox,height:A.checkbox,marginTop:D.spacing.twoXS,marginLeft:0,marginBottom:0,boxShadow:e&&n?D.shadows.focusRing:``,borderLeftWidth:A.borderWidth,borderRightWidth:A.borderWidth,borderTopWidth:A.borderWidth,borderBottomWidth:A.borderWidth,borderLeftColor:r,borderRightColor:r,borderTopColor:r,borderBottomColor:r}}},Label:{style:{lineHeight:D.lineHeights.small,paddingLeft:D.spacing.sm,position:`relative`,color:M}}},children:r(c,{visibility:f(e.labelVisibility?.value),"data-testid":`stWidgetLabel`,children:[n(o,{source:e.label,allowHTML:!1,isLabel:!0,largerLabel:!0}),e.help&&n(u,{content:e.help,placement:l.TOP_RIGHT,label:e.label})]})})})}function y(e,t){return e.getBoolValue(t)}function b(e){return e.default??!1}function x(e){return e.value??!1}function S(e,t,n,r){t.setBoolValue(e,n.value,{fromUi:n.fromUi},r)}var C=(0,_.memo)(v);export{C as default};