import { computed, toRef, createVNode, mergeProps } from "vue";
import { makeSelectionGroupControlProps, SelectionGroupControl } from "../selection-group-control/selection-group-control.mjs";
import { makeSizeProps } from "../../composables/size/index.mjs";
import { makeDensityProps } from "../../composables/density/index.mjs";
import { provideDefaults } from "../../composables/defaults/index.mjs";
import { useProxiedModel } from "../../composables/proxied-model/index.mjs";
import { FormControl } from "../form-control/form-control.mjs";
import { Checkbox } from "../checkbox/checkbox.mjs";
import { defineComponent } from "../../utils/define-component.mjs";
import { getUid } from "../../utils/dist/index.mjs";
const CheckboxGroup = defineComponent({
  name: "VeCheckboxGroup",
  props: {
    items: Array,
    ...makeSelectionGroupControlProps({
      type: "checkbox",
      falseIcon: "$checkboxOff",
      trueIcon: "$checkboxOn",
      multiple: true
    }),
    ...makeSizeProps(),
    ...makeDensityProps()
  },
  emits: {
    "update:modelValue": (_val) => true
  },
  setup(props, {
    slots
  }) {
    const id = computed(() => props.id || `ve-checkbox-group-${getUid()}`);
    const model = useProxiedModel(props, "modelValue");
    const items = computed(() => {
      var _a;
      return (_a = props.items) == null ? void 0 : _a.map((itemProps) => typeof itemProps === "string" ? {
        value: itemProps
      } : itemProps);
    });
    provideDefaults({
      VeCheckbox: {
        size: toRef(props, "size"),
        density: toRef(props, "density"),
        readonly: toRef(props, "readonly"),
        disabled: toRef(props, "disabled")
      }
    });
    return () => {
      const {
        density,
        size,
        ...restProps
      } = props;
      return createVNode(FormControl, {
        "class": "ve-checkbox-group",
        "density": density,
        "name": props.name,
        "size": size,
        "modelValue": model.value,
        "onUpdate:modelValue": ($event) => model.value = $event
      }, {
        ...slots,
        default: ({
          isDisabled,
          isReadonly,
          props: controlProps
        }) => {
          return createVNode(SelectionGroupControl, mergeProps(restProps, controlProps, {
            "id": id.value,
            "disabled": isDisabled.value,
            "readonly": isReadonly.value,
            "modelValue": model.value,
            "onUpdate:modelValue": ($event) => model.value = $event
          }), {
            default: () => {
              var _a, _b;
              return [(_a = items.value) == null ? void 0 : _a.map((itemProps) => createVNode(Checkbox, itemProps, null)), (_b = slots.default) == null ? void 0 : _b.call(slots)];
            }
          });
        }
      });
    };
  }
});
export {
  CheckboxGroup
};
//# sourceMappingURL=checkbox-group.mjs.map
