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 { Radio } from "../radio/radio.mjs";
import { defineComponent } from "../../utils/define-component.mjs";
import { getUid } from "../../utils/dist/index.mjs";
const RadioGroup = defineComponent({
  name: "VeRadioGroup",
  props: {
    items: Array,
    ...makeSelectionGroupControlProps({
      type: "radio",
      trueIcon: "$radioOn",
      falseIcon: "$radioOff"
    }),
    ...makeSizeProps(),
    ...makeDensityProps()
  },
  emits: {
    "update:modelValue": (_modelValue) => true
  },
  setup(props, {
    slots
  }) {
    const id = computed(() => props.id || `ve-radio-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({
      VeRadio: {
        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-radio-group",
        "density": density,
        "name": props.name,
        "size": size,
        "modelValue": model.value,
        "onUpdate:modelValue": ($event) => model.value = $event
      }, {
        ...slots,
        default: ({
          isDisabled,
          isReadonly,
          props: controlProps
        }) => 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(Radio, itemProps, null)), (_b = slots.default) == null ? void 0 : _b.call(slots)];
          }
        })
      });
    };
  }
});
export {
  RadioGroup
};
//# sourceMappingURL=radio-group.mjs.map
