import{r as p,u as T,h as k,j as c,S as C,e as y,l as S,f as L,g as W,T as B,P as R,t as w,C as E}from"./index-BwsrXI9O.js";import{u as P}from"./useBasicWidgetState-CQoPeUHV.js";import{S as j,L as $,a as m}from"./checkbox-2-JpNSRW.js";import"./FormClearHelper-DGQP9oxJ.js";function v({element:t,disabled:a,widgetMgr:n,fragmentId:d}){const[f,g]=P({getStateFromWidgetMgr:X,getDefaultStateFromProto:H,getCurrStateFromProto:M,updateWidgetMgrState:V,element:t,widgetMgr:n,fragmentId:d}),x=p.useCallback(i=>{g({value:i.target.checked,fromUi:!0})},[g]),e=T(),{colors:o,spacing:h,sizes:r}=e,u=k(e),b=a?o.fadedText40:o.bodyText;return c.jsx(C,{className:"row-widget stCheckbox","data-testid":"stCheckbox",children:c.jsx(j,{checked:f,disabled:a,onChange:x,"aria-label":t.label,checkmarkType:t.type===E.StyleType.TOGGLE?m.toggle:m.default,labelPlacement:$.right,overrides:{Root:{style:({$isFocusVisible:i})=>({marginBottom:h.none,marginTop:h.none,backgroundColor:i?o.darkenedBgMix25:"",display:"flex",alignItems:"start"})},Toggle:{style:({$checked:i})=>{let s=u?o.bgColor:o.bodyText;return a&&(s=u?o.gray70:o.gray90),{width:`calc(${r.checkbox} - ${e.spacing.twoXS})`,height:`calc(${r.checkbox} - ${e.spacing.twoXS})`,transform:i?`translateX(${r.checkbox})`:"",backgroundColor:s,boxShadow:""}}},ToggleTrack:{style:({$checked:i,$isHovered:s})=>{let l=o.fadedText40;return s&&!a&&(l=o.fadedText20),i&&!a&&(l=o.primary),{marginRight:0,marginLeft:0,marginBottom:0,marginTop:e.spacing.twoXS,paddingLeft:e.spacing.threeXS,paddingRight:e.spacing.threeXS,width:`calc(2 * ${r.checkbox})`,minWidth:`calc(2 * ${r.checkbox})`,height:r.checkbox,minHeight:r.checkbox,borderBottomLeftRadius:e.radii.full,borderTopLeftRadius:e.radii.full,borderBottomRightRadius:e.radii.full,borderTopRightRadius:e.radii.full,backgroundColor:l}}},Checkmark:{style:({$isFocusVisible:i,$checked:s})=>{const l=s&&!a?o.primary:o.fadedText40;return{outline:0,width:r.checkbox,height:r.checkbox,marginTop:e.spacing.twoXS,marginLeft:0,marginBottom:0,boxShadow:i&&s?`0 0 0 0.2rem ${w(o.primary,.5)}`:"",borderLeftWidth:r.borderWidth,borderRightWidth:r.borderWidth,borderTopWidth:r.borderWidth,borderBottomWidth:r.borderWidth,borderLeftColor:l,borderRightColor:l,borderTopColor:l,borderBottomColor:l}}},Label:{style:{lineHeight:e.lineHeights.small,paddingLeft:e.spacing.sm,position:"relative",color:b}}},children:c.jsxs(y,{visibility:S(t.labelVisibility?.value),"data-testid":"stWidgetLabel",children:[c.jsx(L,{source:t.label,allowHTML:!1,isLabel:!0,largerLabel:!0}),t.help&&c.jsx(W,{color:b,children:c.jsx(B,{content:t.help,placement:R.TOP_RIGHT})})]})})})}function X(t,a){return t.getBoolValue(a)}function H(t){return t.default??null}function M(t){return t.value??null}function V(t,a,n,d){a.setBoolValue(t,n.value,{fromUi:n.fromUi},d)}const U=p.memo(v);export{U as default};
