import{o as e}from"./rolldown-runtime.C0FnF6B9.js";import{r as t}from"./emotion-is-prop-valid.esm.CuYlOKOk.js";import{a as n,i as r,r as i}from"./emotion-styled.browser.esm.BYv_Qzcq.js";import{l as a}from"./protobuf.Ckf-kxfD.js";import{ot as o}from"./utils.Vs712G4Z.js";import{r as s}from"./StreamlitMarkdown.BYA62LKI.js";import{t as c}from"./Tooltip.CcubhKj6.js";import{a as l,c as u,i as d,n as f,o as p,r as m,s as h,t as g}from"./styled-components.3il69GG_.js";import{t as _}from"./useLabelTitleTooltip.VS7apAPP.js";import{t as v}from"./useResolvedWrap.DnjqnyWR.js";import{t as y}from"./WidgetLabelHelpIconInline.CxEaud35.js";import{n as b}from"./useBasicWidgetState.ssY2f7Zy.js";var x=e(t(),1);function S({element:e,disabled:t,widgetMgr:S,fragmentId:D}){let O=e.queryParamKey?{paramKey:e.queryParamKey,valueType:`bool_value`,clearable:!1}:void 0,[k,A]=b({getStateFromWidgetMgr:C,getDefaultStateFromProto:w,getCurrStateFromProto:T,updateWidgetMgrState:E,element:e,widgetMgr:S,fragmentId:D,formClearBehavior:`resetValueOnly`,queryParamBinding:O}),j=(0,x.useCallback)(e=>{A({value:e,fromUi:!0})},[A]),M=e.type===a.StyleType.TOGGLE,N=o(e.labelVisibility?.value),P=!v(e.wrap),{titleRef:F,labelTextRef:I}=_(P,e.label),L=n(d,{visibility:N,$truncate:P,"data-testid":`stWidgetLabel`,children:[r(l,{ref:F,$truncate:P,children:r(`span`,{ref:I,style:{display:`contents`},children:r(s,{source:e.label,allowHTML:!1,isLabel:!0,truncate:P})})}),e.help&&r(y,{content:e.help,placement:c.TOP_RIGHT,label:e.label})]});return M?r(g,{className:`row-widget stCheckbox`,"data-testid":`stCheckbox`,children:r(p,{isSelected:k,isDisabled:t,onChange:j,"aria-label":e.label,$truncate:P,children:({isSelected:e,isHovered:t,isDisabled:a})=>n(i,{children:[r(u,{$isSelected:e,$isHovered:t,$isDisabled:a,children:r(h,{$isSelected:e,$isDisabled:a})}),L]})})}):r(g,{className:`row-widget stCheckbox`,"data-testid":`stCheckbox`,children:r(m,{isSelected:k,isDisabled:t,onChange:j,"aria-label":e.label,$truncate:P,children:({isSelected:e,isFocusVisible:t,isDisabled:a})=>n(i,{children:[r(f,{$isSelected:e,$isFocusVisible:t,$isDisabled:a,children:e&&r(`svg`,{viewBox:`0 0 10 8`,"aria-hidden":`true`,children:r(`polyline`,{points:`1 4 4 7 9 1`})})}),L]})})})}function C(e,t){return e.getBoolValue(t)}function w(e){return e.default??!1}function T(e){return e.value??!1}function E(e,t,n,r){t.setBoolValue(e,n.value,{fromUi:n.fromUi},r)}var D=(0,x.memo)(S);export{D as default};