import { defineComponent as _, useSlots as w, computed as B, ref as m, watch as g, openBlock as f, createElementBlock as v, normalizeClass as d, unref as e, withDirectives as k, createElementVNode as s, renderSlot as p, vShow as C, createTextVNode as h, toDisplayString as a, createVNode as N, withCtx as b, createCommentVNode as R } from "vue";
import { Button as V } from "@aplus-frontend/antdv";
import "../../config-provider/index.mjs";
import $ from "./style/index.mjs";
import { useNamespace as x } from "../../config-provider/hooks/use-namespace.mjs";
import { useLocale as D } from "../../config-provider/hooks/use-locale.mjs";
const E = {
  key: 0,
  class: "selected-desc"
}, H = { class: "selected-desc-conut" }, K = { class: "selected-desc-clean" }, F = /* @__PURE__ */ _({
  __name: "ApBatchAction",
  props: {
    selectedRowKeys: {},
    clearAll: {},
    showSelected: { type: Boolean, default: !0 }
  },
  setup(y) {
    const { b: c } = x("ap-batch-action"), { t: r } = D(), A = $("ap-batch-action"), o = y, u = w(), S = B(() => o.selectedRowKeys?.length || 0), n = m(!1), i = m();
    return g(
      () => u.header,
      () => {
        setTimeout(() => {
          const t = u.header?.();
          t?.length === 1 && t?.[0]?.type?.name === "ASpace" ? n.value = !!Array.prototype.slice.call(i.value?.children?.[0]?.children)?.filter?.((l) => l?.children?.length)?.length : n.value = !!i.value?.children?.length;
        });
      },
      {
        immediate: !0
      }
    ), (t, l) => (f(), v("div", {
      class: d([e(c)(), e(A)])
    }, [
      k(s("div", {
        ref_key: "headerRef",
        ref: i,
        class: d(e(c)("header"))
      }, [
        p(t.$slots, "header")
      ], 2), [
        [C, n.value]
      ]),
      s("div", {
        class: d(e(c)("body"))
      }, [
        p(t.$slots, "prefix"),
        o.showSelected ? (f(), v("div", E, [
          s("div", H, [
            h(a(e(r)("ap.apBatchAction.selected")) + " ", 1),
            s("span", null, a(S.value), 1),
            h(" " + a(e(r)("ap.apBatchAction.piecesOfData")), 1)
          ]),
          s("div", K, [
            N(e(V), {
              type: "link",
              onClick: l[0] || (l[0] = (L) => o.clearAll && o.clearAll())
            }, {
              default: b(() => [
                h(a(e(r)("ap.apBatchAction.empty")), 1)
              ]),
              _: 1
            })
          ])
        ])) : R("", !0),
        p(t.$slots, "suffix")
      ], 2)
    ], 2));
  }
});
export {
  F as default
};
