import { defineComponent as A, useSlots as F, createPropsRestProxy as N, ref as P, computed as a, unref as t, openBlock as l, createBlock as d, normalizeProps as S, guardReactiveProps as V, withCtx as y, renderSlot as v, createElementBlock as f, mergeProps as k, createVNode as b, normalizeClass as I, createElementVNode as L, resolveDynamicComponent as x, createCommentVNode as m, isVNode as $, toDisplayString as z } from "vue";
import { Tooltip as C } from "@aplus-frontend/antdv";
import D from "@aplus-frontend/antdv/es/button/LoadingIcon";
import "../../config-provider/index.mjs";
import E from "../style/index.mjs";
import { useNamespace as R } from "../../config-provider/hooks/use-namespace.mjs";
const W = { key: 1 }, O = /* @__PURE__ */ A({
  name: "ApActionItem",
  __name: "index",
  props: {
    text: {},
    color: { default: "primary" },
    disabled: { type: Boolean, default: !1 },
    visible: { type: Boolean, default: !0 },
    onAction: { type: Function },
    onClick: { type: Function },
    loading: { type: Boolean, default: !1 },
    icon: {},
    iconFirst: { type: Boolean, default: !1 },
    tooltip: { default: () => ({}) },
    wrapperTooltip: {}
  },
  setup(e) {
    const r = F(), c = N(e, ["color", "disabled", "visible", "loading", "iconFirst", "icon", "tooltip", "wrapperTooltip"]), { b: p, m: i, e: T } = R("action-item"), s = P(!1), u = a(() => e.iconFirst && !!(e.icon || r.icon)), w = E("action-item");
    function g(o) {
      t(n) || e.disabled || (c.onClick?.(o), c.onAction && (s.value = !0, c.onAction(o).finally(() => s.value = !1)));
    }
    const n = a(() => e.loading || t(s)), B = a(() => e.wrapperTooltip ? typeof e.wrapperTooltip == "string" ? { title: e.wrapperTooltip } : { ...e.wrapperTooltip } : {
      title: null
    }), h = a(() => [
      w.value,
      p(),
      i(e.color),
      u.value ? i("icon-first") : null,
      e.disabled ? i("disabled") : null,
      n.value ? i("loading") : null
    ].filter(Boolean));
    return (o, j) => (l(), d(t(C), S(V(B.value)), {
      default: y(() => [
        v(o.$slots, "trigger", {
          loading: n.value,
          disabled: e.disabled,
          onClick: g
        }, () => [
          e.visible ? (l(), f("span", k({ key: 0 }, o.$attrs, {
            class: h.value,
            onClick: g
          }), [
            b(t(D), {
              "prefix-cls": t(p)(),
              "exist-icon": !1,
              loading: n.value
            }, null, 8, ["prefix-cls", "loading"]),
            e.icon || r.icon ? (l(), f("span", {
              key: 0,
              class: I(t(T)("icon-wrapper"))
            }, [
              b(t(C), k({
                title: u.value ? e.text : null
              }, e.tooltip), {
                default: y(() => [
                  L("span", null, [
                    (l(), d(x(e.icon || r.icon)))
                  ])
                ]),
                _: 1
              }, 16, ["title"])
            ], 2)) : m("", !0),
            u.value ? m("", !0) : v(o.$slots, "default", { key: 1 }, () => [
              $(e.text) ? (l(), d(x(e.text), { key: 0 })) : (l(), f("span", W, z(e.text || ""), 1))
            ])
          ], 16)) : m("", !0)
        ])
      ]),
      _: 3
    }, 16));
  }
});
export {
  O as default
};
