"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const Vue = require("vue");
const index_esm = require("../../../@vant/use/dist/index.esm.js");
const useExpose = require("../composables/use-expose.js");
const create = require("../utils/create.js");
const props = require("../utils/props.js");
const [name, bem] = create.createNamespace("checkbox-group");
const checkboxGroupProps = {
  max: props.numericProp,
  shape: props.makeStringProp("round"),
  disabled: Boolean,
  iconSize: props.numericProp,
  direction: String,
  modelValue: props.makeArrayProp(),
  checkedColor: String
};
const CHECKBOX_GROUP_KEY = Symbol(name);
var stdin_default = Vue.defineComponent({
  name,
  props: checkboxGroupProps,
  emits: ["change", "update:modelValue"],
  setup(props2, {
    emit,
    slots
  }) {
    const {
      children,
      linkChildren
    } = index_esm.useChildren(CHECKBOX_GROUP_KEY);
    const updateValue = (value) => emit("update:modelValue", value);
    const toggleAll = (options = {}) => {
      if (typeof options === "boolean") {
        options = {
          checked: options
        };
      }
      const {
        checked,
        skipDisabled
      } = options;
      const checkedChildren = children.filter((item) => {
        if (!item.props.bindGroup) {
          return false;
        }
        if (item.props.disabled && skipDisabled) {
          return item.checked.value;
        }
        return checked != null ? checked : !item.checked.value;
      });
      const names = checkedChildren.map((item) => item.name);
      updateValue(names);
    };
    Vue.watch(() => props2.modelValue, (value) => emit("change", value));
    useExpose.useExpose({
      toggleAll
    });
    index_esm.useCustomFieldValue(() => props2.modelValue);
    linkChildren({
      props: props2,
      updateValue
    });
    return () => {
      var _a;
      return Vue.createVNode("div", {
        "class": bem([props2.direction])
      }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
    };
  }
});
exports.CHECKBOX_GROUP_KEY = CHECKBOX_GROUP_KEY;
exports.checkboxGroupProps = checkboxGroupProps;
exports.default = stdin_default;
