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.Dj5rZcu_.js";import{l as a}from"./protobuf.D2FOsaUI.js";import{ot as o}from"./utils.Bid3C9ZE.js";import{r as s,u as c}from"./StreamlitMarkdown.DYzuPhFL.js";import{t as l}from"./Tooltip.bbzhtE2V.js";import{t as u}from"./WidgetLabelHelpIconInline.6Cy34Tnv.js";import{A as d,F as f,G as p,I as m,L as h,M as g,N as _,P as v,j as y}from"./index.ByR4Z2EF.js";import{n as b}from"./useBasicWidgetState.CmWXqZwl.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,fromUser:!0})},[A]),M=e.type===a.StyleType.TOGGLE,N=o(e.labelVisibility?.value),P=!p(e.wrap),{titleRef:F,labelTextRef:I}=c(P,e.label),L=n(_,{visibility:N,$truncate:P,"data-testid":`stWidgetLabel`,children:[r(v,{ref:F,$truncate:P,children:r(`span`,{ref:I,style:{display:`contents`},children:r(s,{source:e.label,allowHTML:!1,isLabel:!0,truncate:P,inheritLineHeight:!0})})}),e.help&&r(u,{content:e.help,placement:l.TOP_RIGHT,label:e.label})]});return M?r(d,{className:`row-widget stCheckbox`,"data-testid":`stCheckbox`,children:r(f,{isSelected:k,isDisabled:t,onChange:j,"aria-label":e.label,$truncate:P,children:({isSelected:e,isHovered:t,isDisabled:a})=>n(i,{children:[r(h,{$isSelected:e,$isHovered:t,$isDisabled:a,children:r(m,{$isSelected:e,$isDisabled:a})}),L]})})}):r(d,{className:`row-widget stCheckbox`,"data-testid":`stCheckbox`,children:r(g,{isSelected:k,isDisabled:t,onChange:j,"aria-label":e.label,$truncate:P,children:({isSelected:e,isFocusVisible:t,isDisabled:a})=>n(i,{children:[r(y,{$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.id,n.value,{formId:e.formId,fragmentId:r,fromUser:n.fromUser})}var D=(0,x.memo)(S);export{D as default};