import { computed, createVNode, mergeProps, isVNode } from "vue";
import { useProxiedModel } from "../../composables/proxied-model/index.mjs";
import { makeSelectionControlProps, filterSelectionControlProps, SelectionControl } from "../selection-control/selection-control.mjs";
import { defineComponent } from "../../utils/define-component.mjs";
function _isSlot(s) {
  return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
}
const Checkbox = defineComponent({
  name: "VeCheckbox",
  props: {
    indeterminate: Boolean,
    indeterminateIcon: {
      type: String,
      default: "$checkboxIndeterminate"
    },
    ...makeSelectionControlProps({
      type: "checkbox",
      falseIcon: "$checkboxOff",
      trueIcon: "$checkboxOn",
      color: "primary"
    })
  },
  emits: {
    "update:modelValue": (_val) => true,
    "update:indeterminate": (_val) => true
  },
  setup(props, {
    emit,
    slots
  }) {
    const indeterminate = useProxiedModel(props, "indeterminate");
    const falseIcon = computed(() => {
      return indeterminate.value ? props.indeterminateIcon : props.falseIcon;
    });
    const trueIcon = computed(() => {
      return indeterminate.value ? props.indeterminateIcon : props.trueIcon;
    });
    function onChange(val) {
      if (indeterminate.value) {
        indeterminate.value = false;
      } else {
        emit("update:modelValue", val);
      }
    }
    return () => {
      const [controlProps] = filterSelectionControlProps(props);
      return createVNode(SelectionControl, mergeProps(controlProps, {
        "class": "ve-checkbox",
        "onUpdate:modelValue": onChange,
        "falseIcon": falseIcon.value,
        "trueIcon": trueIcon.value,
        "aria-checked": indeterminate.value ? "mixed" : void 0
      }), _isSlot(slots) ? slots : {
        default: () => [slots]
      });
    };
  }
});
export {
  Checkbox
};
//# sourceMappingURL=checkbox.mjs.map
