"use strict";const t=require("vue"),f=require("./CdxLabel.cjs"),h=require("./useLabelChecker.js"),k=require("./useModelWrapper.cjs"),C=require("./useFieldData.cjs"),c=require("./constants.js"),y=require("./_plugin-vue_export-helper.js"),v=c.makeStringTypeValidator(c.ValidationStatusTypes),$=t.defineComponent({name:"CdxCheckbox",components:{CdxLabel:f},props:{modelValue:{type:[Boolean,Array],default:!1},inputValue:{type:[String,Number,Boolean],default:!1},name:{type:String,default:null},disabled:{type:Boolean,default:!1},indeterminate:{type:Boolean,default:!1},inline:{type:Boolean,default:!1},hideLabel:{type:Boolean,default:!1},status:{type:String,default:"default",validator:v}},emits:["update:modelValue"],setup(e,{emit:o,slots:s,attrs:l}){var r;h.useLabelChecker((r=s.default)==null?void 0:r.call(s),l,"CdxCheckbox");const{computedDisabled:i,computedStatus:a}=C(t.toRef(e,"disabled"),t.toRef(e,"status")),d=t.computed(()=>({"cdx-checkbox--inline":e.inline,["cdx-checkbox--status-".concat(a.value)]:!0})),n=t.computed(()=>({"cdx-checkbox__custom-input--inline":e.inline})),u=t.ref(),p=t.useId(),m=t.useId(),b=k(t.toRef(e,"modelValue"),o);return{rootClasses:d,computedDisabled:i,input:u,checkboxId:p,descriptionId:m,wrappedModel:b,customInputClasses:n}}}),V={class:"cdx-checkbox__wrapper"},x=["id","aria-describedby","value","name","disabled",".indeterminate"];function B(e,o,s,l,i,a){const d=t.resolveComponent("cdx-label");return t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["cdx-checkbox",e.rootClasses])},[t.createElementVNode("div",V,[t.withDirectives(t.createElementVNode("input",{id:e.checkboxId,ref:"input","onUpdate:modelValue":o[0]||(o[0]=n=>e.wrappedModel=n),class:"cdx-checkbox__input",type:"checkbox","aria-describedby":e.$slots.description&&e.$slots.description().length>0?e.descriptionId:void 0,value:e.inputValue,name:e.name,disabled:e.computedDisabled,".indeterminate":e.indeterminate},null,40,x),[[t.vModelCheckbox,e.wrappedModel]]),o[1]||(o[1]=t.createElementVNode("span",{class:"cdx-checkbox__icon"},null,-1)),e.$slots.default&&e.$slots.default().length?(t.openBlock(),t.createBlock(d,{key:0,class:"cdx-checkbox__label","input-id":e.checkboxId,"description-id":e.$slots.description&&e.$slots.description().length>0?e.descriptionId:void 0,disabled:e.computedDisabled,"visually-hidden":e.hideLabel},t.createSlots({default:t.withCtx(()=>[t.renderSlot(e.$slots,"default")]),_:2},[e.$slots.description&&e.$slots.description().length>0?{name:"description",fn:t.withCtx(()=>[t.renderSlot(e.$slots,"description")]),key:"0"}:void 0]),1032,["input-id","description-id","disabled","visually-hidden"])):t.createCommentVNode("v-if",!0)]),e.$slots["custom-input"]?(t.openBlock(),t.createElementBlock("div",{key:0,class:t.normalizeClass(["cdx-checkbox__custom-input",e.customInputClasses])},[t.renderSlot(e.$slots,"custom-input")],2)):t.createCommentVNode("v-if",!0)],2)}const I=y._export_sfc($,[["render",B]]);module.exports=I;
