import { defineComponent as O, computed as T, useSlots as P, ref as U, onMounted as F, openBlock as o, createElementBlock as l, Fragment as r, unref as e, createTextVNode as d, toDisplayString as f, createBlock as v, mergeProps as N, createSlots as _, renderList as z, withCtx as A, renderSlot as L, normalizeProps as M, guardReactiveProps as R } from "vue";
import { Spin as j, CheckboxGroup as w } from "@aplus-frontend/antdv";
import { omit as D, isFunction as E, isNil as G } from "lodash-unified";
import "../../config-provider/index.mjs";
import "../../hooks/index.mjs";
import I from "../hooks/use-options.mjs";
import $ from "../style/index.mjs";
import { getOptionValue as H, getOptionLabel as J } from "./helper.mjs";
import { useNamespace as K } from "../../config-provider/hooks/use-namespace.mjs";
import { useControllableValue as Q } from "../../hooks/useControllableValue.mjs";
const se = /* @__PURE__ */ O({
  name: "ApFieldCheckbox",
  inheritAttrs: !1,
  __name: "index",
  props: {
    mode: { default: "edit" },
    class: {},
    style: {},
    emptyText: { default: "--" },
    customReadMode: {},
    defaultValue: {},
    value: {},
    onChange: {},
    "onUpdate:value": {},
    name: {},
    prefixCls: {},
    options: { default: () => [] },
    disabled: { type: Boolean, default: void 0 },
    id: {},
    request: {},
    vertical: { type: Boolean }
  },
  emits: ["update:value"],
  setup(n, { expose: y, emit: x }) {
    const k = x, t = n, h = T(
      () => D(t, ["onUpdate:value", "value", "request", "vertical", "emptyText"])
    ), g = P(), { options: p, updateOptions: b } = I(t), { b: C, m: S } = K("field-checkbox"), V = $("field"), s = U(!1);
    async function m() {
      if (E(t.request))
        return s.value = !0, t.request().then((u) => b(u)).finally(() => {
          s.value = !1;
        });
    }
    F(() => {
      m();
    });
    const { value: i, updateValue: q } = Q(
      t,
      k,
      {
        defaultValue: []
      }
    );
    return y({
      request: m
    }), (u, W) => n.mode === "read" ? (o(), l(r, { key: 0 }, [
      e(G)(e(i)) ? (o(), l(r, { key: 0 }, [
        d(f(t.emptyText), 1)
      ], 64)) : (o(), l(r, { key: 1 }, [
        d(f(e(p)?.filter((a) => e(i).indexOf(e(H)(a)) > -1).map((a) => e(J)(a)).join("、") || t.emptyText), 1)
      ], 64))
    ], 64)) : (o(), l(r, { key: 1 }, [
      s.value ? (o(), v(e(j), {
        key: 0,
        size: "small"
      })) : (o(), v(e(w), N({ key: 1 }, h.value, {
        options: e(p),
        value: e(i),
        class: [e(C)(), n.vertical ? e(S)("vertical") : null, e(V)],
        "onUpdate:value": e(q)
      }), _({ _: 2 }, [
        z(g, (a, c) => ({
          name: c,
          fn: A((B) => [
            L(u.$slots, c, M(R(B || {})))
          ])
        }))
      ]), 1040, ["options", "value", "class", "onUpdate:value"]))
    ], 64));
  }
});
export {
  se as default
};
