"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("../../common/mixins/input.cjs"),o=require("../../common/utils/index.cjs"),r=require("./checkbox-constants.cjs"),s=require("vue"),d=require("../../_plugin-vue_export-helper-BRilXfQE.cjs"),c=require("../validation-messages/validation-messages.cjs"),u={compatConfig:{MODE:3},name:"DtCheckbox",components:{DtValidationMessages:c.default},mixins:[l.InputMixin,l.CheckableMixin,l.GroupableMixin,l.MessagesMixin],inheritAttrs:!1,emits:["input","update:modelValue","focusin","focusout"],computed:{inputValidationClass(){return r.CHECKBOX_INPUT_VALIDATION_CLASSES[this.internalValidationState]},checkboxGroupValueChecked(){var e,a;return((a=(e=this.groupContext)==null?void 0:e.selectedValues)==null?void 0:a.includes(this.value))??!1},hasLabel(){return!!(this.$slots.default||this.label)},hasMessages(){return this.formattedMessages.length&&this.showMessages},inputListeners(){return{input:()=>{},focusin:e=>this.$emit("focusin",e),focusout:e=>this.$emit("focusout",e),change:e=>this.emitValue(e.target)}}},watch:{checkboxGroupValueChecked:{immediate:!0,handler(e){this.hasGroup&&(this.internalChecked=e)}}},mounted(){this.runValidations()},methods:{removeClassStyleAttrs:o.removeClassStyleAttrs,addClassStyleAttrs:o.addClassStyleAttrs,emitValue(e){let{value:a,checked:i}=e;this.internalIndeterminate&&(i=!1,this.internalIndeterminate=!1,e.checked=!1),this.setGroupValue(a,i),this.$emit("input",i),this.$emit("update:modelValue",i)},runValidations(){this.validateInputLabels(this.hasLabel,this.$attrs["aria-label"])}}},h={class:"d-checkbox__input"},m=["checked","name","value","disabled",".indeterminate"],p={key:0,class:"d-checkbox__messages","data-qa":"checkbox-description-messages"};function b(e,a,i,g,C,t){const n=s.resolveComponent("dt-validation-messages");return s.openBlock(),s.createElementBlock("div",s.normalizeProps(s.guardReactiveProps(t.addClassStyleAttrs(e.$attrs))),[s.createElementVNode("label",{class:s.normalizeClass(["d-checkbox-group",{"d-checkbox-group--disabled":e.internalDisabled}])},[s.createElementVNode("div",h,[s.createElementVNode("input",s.mergeProps({type:"checkbox",checked:e.internalChecked,name:e.internalName,value:e.value,disabled:e.internalDisabled,class:["d-checkbox",t.inputValidationClass,e.inputClass]},t.removeClassStyleAttrs(e.$attrs),{".indeterminate":e.internalIndeterminate},s.toHandlers(t.inputListeners,!0)),null,48,m)]),t.hasLabel?(s.openBlock(),s.createElementBlock("div",s.mergeProps({key:0,class:[e.labelClass,"d-checkbox__copy d-checkbox__label"]},e.labelChildProps,{"data-qa":"checkbox-label"}),[s.renderSlot(e.$slots,"default",{},()=>[s.createTextVNode(s.toDisplayString(e.label),1)])],16)):s.createCommentVNode("",!0)],2),e.$slots.description||e.description||t.hasMessages?(s.openBlock(),s.createElementBlock("div",p,[e.$slots.description||e.description?(s.openBlock(),s.createElementBlock("div",s.mergeProps({key:0,class:["d-description",e.descriptionClass]},e.descriptionChildProps,{"data-qa":"checkbox-description"}),[s.renderSlot(e.$slots,"description",{},()=>[s.createTextVNode(s.toDisplayString(e.description),1)])],16)):s.createCommentVNode("",!0),s.createVNode(n,s.mergeProps({"validation-messages":e.formattedMessages,"show-messages":e.showMessages,class:e.messagesClass},e.messagesChildProps,{"data-qa":"dt-checkbox-validation-messages"}),null,16,["validation-messages","show-messages","class"])])):s.createCommentVNode("",!0)],16)}const k=d._(u,[["render",b]]);exports.default=k;
//# sourceMappingURL=checkbox.cjs.map
