import{j as e}from"./fields-wnm5Jtc6.js";import{R as i}from"./vendor-D21mNUGX.js";import{P as r,I as u}from"./index-pmrLY__j.js";import{g as x,C as f}from"./index.esm-DCQn2FO4.js";const g=({id:s,icon:l,control:d,defaultValue:t=!1,errors:m,disabled:c=!1,externalOnChange:o})=>{const a=x(m,s);return e.jsx(i.Fragment,{children:e.jsx(f,{control:d,name:s,defaultValue:t,render:({field:{onChange:h,onBlur:p,value:j,ref:b}})=>e.jsxs(i.Fragment,{children:[e.jsx("input",{className:"hidden",type:"checkbox",id:s,disabled:c,checked:t||!1,onBlur:p,onChange:n=>{h(n.currentTarget.checked),o&&o({id:s,checked:n.currentTarget.checked})}}),e.jsx("label",{htmlFor:s,className:`acpt-btn-switch ${t===!0?"active":""} ${c===!0?"disabled":""}`,children:e.jsx(u,{icon:l,width:18})}),a&&e.jsx("div",{className:"invalid-feedback",children:a.message})]})})})};g.propTypes={id:r.string.isRequired,control:r.func.isRequired,icon:r.string.isRequired,defaultValue:r.bool,errors:r.array.isRequired,disabled:r.bool,externalOnChange:r.func};export{g as B};
