import { defineComponent as P, ref as U, computed as k, unref as n, watch as D, openBlock as s, createElementBlock as w, normalizeClass as b, createElementVNode as g, createVNode as i, withCtx as d, createBlock as u, resolveDynamicComponent as C, Fragment as L, renderList as j, mergeProps as z } from "vue";
import { Checkbox as y, Row as F, Col as I } from "@aplus-frontend/antdv";
import "../../../../config-provider/index.mjs";
import { useInjectApTable as R } from "../../../context.mjs";
import { getLabelNode as _ } from "../utils.mjs";
import { useNamespace as T } from "../../../../config-provider/hooks/use-namespace.mjs";
const M = /* @__PURE__ */ P({
  __name: "index",
  props: {
    value: {}
  },
  setup(h) {
    const r = h, { b: m } = T("ap-column-setting-select-group"), c = U(!1), { columnsBackup: S, renderConfig: f } = R(), p = k(() => n(S)?.find(
      (t) => t.key === r.value?.key
    ));
    function A(e) {
      const t = r.value.children.find((o) => o.key === e.key);
      return {
        checked: t?.show,
        disabled: r.value.disabled || t?.disabled
      };
    }
    function B(e) {
      const t = r.value;
      t.children.forEach((o) => o.show = e), t.show = e, c.value = !1;
    }
    function N(e, t) {
      const o = r.value, a = o.children.find((l) => l.key === e);
      if (!a)
        return;
      a.show = t;
      const v = o.children.every((l) => l.show), E = o.children.some((l) => l.show);
      o.show = v, c.value = E && !v;
    }
    const x = k(() => r.value.disabled || r.value.children.every((e) => e.disabled));
    return D(
      () => r.value,
      (e) => {
        const t = e.children.every((a) => a.show), o = e.children.some((a) => a.show);
        c.value = o && !t, e.show !== t && (e.show = t);
      },
      {
        deep: !0,
        immediate: !0
      }
    ), (e, t) => (s(), w("div", {
      class: b(n(m)())
    }, [
      g("div", {
        class: b(n(m)("header"))
      }, [
        i(n(y), {
          indeterminate: c.value,
          checked: h.value?.show,
          disabled: x.value,
          "onUpdate:checked": B
        }, {
          default: d(() => [
            (s(), u(C(n(_)(p.value, n(f)))))
          ]),
          _: 1
        }, 8, ["indeterminate", "checked", "disabled"])
      ], 2),
      g("div", null, [
        i(n(F), {
          align: "middle",
          gutter: 24
        }, {
          default: d(() => [
            (s(!0), w(L, null, j(p.value.children, (o) => (s(), u(n(I), {
              key: o.key,
              span: 12
            }, {
              default: d(() => [
                i(n(y), z({ ref_for: !0 }, A(o), {
                  "onUpdate:checked": (a) => N(o.key, a)
                }), {
                  default: d(() => [
                    (s(), u(C(n(_)(o, n(f)))))
                  ]),
                  _: 2
                }, 1040, ["onUpdate:checked"])
              ]),
              _: 2
            }, 1024))), 128))
          ]),
          _: 1
        })
      ])
    ], 2));
  }
});
export {
  M as default
};
