import { defineComponent as V, computed as p, ref as C, onMounted as O, unref as e, openBlock as a, createElementBlock as m, Fragment as d, createTextVNode as R, toDisplayString as S, createBlock as c, mergeProps as U } from "vue";
import { Spin as N, RadioGroup as z } from "@aplus-frontend/antdv";
import { omit as F, isNil as G } from "lodash-unified";
import "../../config-provider/index.mjs";
import "../../hooks/index.mjs";
import M from "../hooks/use-options.mjs";
import P from "../style/index.mjs";
import { getOptionValue as _, getOptionLabel as A } from "./helper.mjs";
import { useControllableValue as D } from "../../hooks/useControllableValue.mjs";
import { useNamespace as E } from "../../config-provider/hooks/use-namespace.mjs";
const Y = /* @__PURE__ */ V({
  name: "ApFieldRadio",
  __name: "index",
  props: {
    mode: { default: "edit" },
    class: {},
    style: {},
    emptyText: { default: "--" },
    customReadMode: {},
    prefixCls: {},
    value: {},
    size: {},
    options: {},
    disabled: { type: Boolean, default: void 0 },
    name: {},
    buttonStyle: {},
    id: {},
    block: { type: Boolean },
    optionType: {},
    onChange: {},
    "onUpdate:value": {},
    vertical: { type: Boolean, default: !1 },
    request: {}
  },
  emits: ["update:value"],
  setup(l, { expose: f, emit: v }) {
    const t = l, y = p(
      () => F(t, ["value", "onUpdate:value", "options", "request", "vertical"])
    ), x = v, { options: r, updateOptions: g } = M(t), { value: s, updateValue: k } = D(t, x), { b, m: B } = E("field-radio"), T = P("field"), n = C(!1);
    async function i() {
      t.request && (n.value = !0, t.request?.().then((o) => g(o)).finally(() => {
        n.value = !1;
      }));
    }
    O(() => {
      i();
    });
    const h = p(() => {
      const o = e(s);
      if (G(o))
        return t.emptyText;
      const u = r.value?.find(
        (q) => o === _(q)
      );
      return A(u) || t.emptyText;
    });
    return f({
      request: i
    }), (o, u) => l.mode === "read" ? (a(), m(d, { key: 0 }, [
      R(S(h.value), 1)
    ], 64)) : (a(), m(d, { key: 1 }, [
      n.value ? (a(), c(e(N), {
        key: 0,
        size: "small"
      })) : (a(), c(e(z), U({ key: 1 }, y.value, {
        ref: "radioGroupRef",
        value: e(s),
        options: e(r),
        class: [e(b)(), l.vertical ? e(B)("vertical") : null, e(T)],
        "onUpdate:value": e(k)
      }), null, 16, ["value", "options", "class", "onUpdate:value"]))
    ], 64));
  }
});
export {
  Y as default
};
