import { warn as s } from "vue";
import l from "../input-group/input-group.js";
const n = {
  compatConfig: { MODE: 3 },
  name: "DtCheckboxGroup",
  extends: l,
  props: {
    /**
     * Not supported by this component, please use selectedValues
     */
    modelValue: {
      type: [],
      default: null,
      validator: (e) => e ? (s(
        "Component uses selectedValues to initialize the model, modelValue is not supported by this component",
        void 0
      ), !1) : !0
    },
    /**
     * A provided list of selected values(s) for the checkbox group
     * @model selectedValues
     */
    selectedValues: {
      type: Array,
      default() {
        return [];
      }
    },
    /**
     * A data qa tag for the radio group
     */
    dataQaGroup: {
      type: String,
      default: "checkbox-group"
    },
    /**
     * A data qa tag for the radio group legend
     */
    dataQaGroupLegend: {
      type: String,
      default: "checkbox-group-legend"
    },
    /**
     * A data qa tag for the radio group messages
     */
    dataQaGroupMessages: {
      type: String,
      default: "checkbox-group-messages"
    }
  },
  emits: [
    /**
     * Native input event
     *
     * @event input
     * @type {Array}
     */
    "input",
    /**
     * Selected values for the checkbox group
     *
     * @event input
     * @type {Array}
     */
    "update:selectedValues"
  ],
  data() {
    return {
      internalValue: this.selectedValues
    };
  },
  watch: {
    selectedValues(e) {
      this.internalValue = e;
    },
    /*
    * watching value to support 2 way binding for slotted checkboxes.
    * need this to pass value to slotted checkboxes if modified outside
    * checkbox group.
    */
    internalValue: {
      immediate: !0,
      handler(e) {
        this.provideObj.selectedValues = e;
      }
    }
  },
  methods: {
    /*
     * provided value to support 2 way binding for slotted checkboxes.
     * slotted checkbox will change this value and need to emit new value up.
     */
    setGroupValue(e, t) {
      t ? this.internalValue.includes(e) || this.internalValue.push(e) : this.internalValue = this.internalValue.filter((a) => a !== e), this.$emit("input", this.internalValue), this.$emit("update:selectedValues", this.internalValue);
    },
    getMessageKey(e, t) {
      return `checkbox-group-message-${e}-${t}-${this.id}`;
    }
  }
};
export {
  n as default
};
//# sourceMappingURL=checkbox-group.js.map
