import { defineComponent as q, computed as t, useSlots as F, ref as H, openBlock as i, createBlock as c, unref as n, mergeProps as v, createSlots as k, withCtx as r, createElementVNode as J, normalizeStyle as K, resolveDynamicComponent as L, h as A, createVNode as d, renderList as B, renderSlot as $, normalizeProps as b, guardReactiveProps as h, normalizeClass as M, createCommentVNode as Q } from "vue";
import { DownOutlined as U } from "@ant-design/icons-vue";
import { DropdownButton as W, Dropdown as X } from "@aplus-frontend/antdv";
import { useInjectApTable as Y } from "../../ap-table/context.mjs";
import "../../ap-button/index.mjs";
import "../../config-provider/index.mjs";
import "./MenuItemGroup.vue.mjs";
import Z from "./style/index.mjs";
import { useNamespace as ee } from "../../config-provider/hooks/use-namespace.mjs";
import { useLocale as oe } from "../../config-provider/hooks/use-locale.mjs";
import { useGlobalConfig as te } from "../../config-provider/hooks/use-global-config.mjs";
import D from "./MenuItemGroup.vue2.mjs";
import ne from "../../ap-button/ap-button.vue.mjs";
const he = /* @__PURE__ */ q({
  __name: "ApBatchActionGroup",
  props: {
    selectedRows: {},
    buttonProps: {},
    menuList: {}
  },
  setup(G, { expose: O }) {
    const { b: y } = ee("ap-batch-action-group"), R = Z("ap-batch-action-group"), { t: T } = oe(), { columns: N, dataSource: z } = Y(), o = G, E = te("apExportGroup"), V = t(() => E.value?.hasPermission), w = F(), u = H(!1), g = (e, s) => {
      (s.source === "trigger" || e) && (u.value = e);
    };
    function P(e) {
      u.value = e;
    }
    const _ = t(
      () => o?.buttonProps?.dropdownType || "default"
    ), l = t(
      () => o?.buttonProps?.type || "borderLink"
    ), C = t(
      () => o?.buttonProps?.content || T("ap.apApBatchActionGroup.batchOperation")
    ), x = t(() => o?.selectedRows || []), m = t(
      () => o?.buttonProps?.disabled ?? (Array.isArray(o.selectedRows) ? x.value.length === 0 : !1)
    ), I = t(() => l.value === "borderLink" ? m.value ? void 0 : "var(--ap-button-border-link-color)" : void 0), p = t(() => o?.menuList?.filter((e) => {
      if (e === "divider")
        return !0;
      let s = e?.ifShow;
      return !e?.ifShow && e?.auth && (s = () => V.value?.(e.auth)), s?.() ?? !0;
    }) || []);
    function S() {
      return o?.buttonProps ? {
        ...o.buttonProps,
        type: l.value === "borderLink" ? "default" : l.value
      } : {};
    }
    return O({
      columns: N,
      dataSource: z
    }), (e, s) => p.value.length && _.value === "dropdown" ? (i(), c(n(W), v({
      key: 0,
      class: [n(y)(), n(R)]
    }, {
      ...e.$attrs,
      ...S(),
      disabled: m.value
    }, {
      open: u.value,
      onOpenChange: g
    }), k({
      overlay: r(() => [
        d(D, v({
          ...o
        }, {
          "set-open": P,
          "menu-list": p.value
        }), null, 16, ["menu-list"])
      ]),
      default: r(() => [
        J("span", {
          style: K({
            color: I.value
          })
        }, [
          (i(), c(L(A("span", [C.value]))))
        ], 4)
      ]),
      _: 2
    }, [
      B(w, (j, a) => ({
        name: a,
        fn: r((f) => [
          $(e.$slots, a, b(h(f || {})))
        ])
      }))
    ]), 1040, ["class", "open"])) : p.value.length && _.value === "default" ? (i(), c(n(X), {
      key: 1,
      class: M([n(y)()]),
      disabled: m.value,
      open: u.value,
      onOpenChange: g
    }, k({
      overlay: r(() => [
        d(D, v({
          ...o
        }, {
          "set-open": P,
          "menu-list": p.value
        }), null, 16, ["menu-list"])
      ]),
      default: r(() => [
        d(n(ne), b(h({
          ...e.$attrs,
          ...S(),
          type: l.value
        })), {
          default: r(() => [
            (i(), c(L(A("span", [C.value])))),
            d(n(U))
          ]),
          _: 1
        }, 16)
      ]),
      _: 2
    }, [
      B(w, (j, a) => ({
        name: a,
        fn: r((f) => [
          $(e.$slots, a, b(h(f || {})))
        ])
      }))
    ]), 1032, ["class", "disabled", "open"])) : Q("", !0);
  }
});
export {
  he as default
};
