import '@das-fed/ui/packages/components/button/style.css';
import { withInstall as oe } from "@das-fed/utils/with-install/index";
import { defineComponent as le, ref as W, computed as se, watchEffect as ue, createElementBlock as h, openBlock as s, createCommentVNode as y, createBlock as g, unref as l, mergeProps as B, createSlots as K, withCtx as f, renderSlot as w, createElementVNode as U, createVNode as I, Fragment as $, renderList as N, createTextVNode as A, toDisplayString as L, isRef as de } from "vue";
import { DasAutoRegisterIcon as fe, DasIcon as P } from "@das-fed/ui/packages/components/icon/index";
import { DropdownButton as be, Menu as H, MenuItem as X, Dropdown as ce, Button as q, RadioGroup as me, RadioButton as pe } from "ant-design-vue";
import "ant-design-vue/es/button/style/css";
import "ant-design-vue/es/dropdown/style/css";
import "ant-design-vue/es/radio/style/css";
import { setThemeRule as ye } from "@das-fed/web/packages/theme/index";
var E = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
function ge(t) {
  return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
}
function ve(t) {
  var a = typeof t;
  return t != null && (a == "object" || a == "function");
}
var ee = ve, ke = typeof E == "object" && E && E.Object === Object && E, Te = ke, he = Te, Ce = typeof self == "object" && self && self.Object === Object && self, $e = he || Ce || Function("return this")(), te = $e, je = te, Se = function() {
  return je.Date.now();
}, Ie = Se, Oe = /\s/;
function De(t) {
  for (var a = t.length; a-- && Oe.test(t.charAt(a)); )
    ;
  return a;
}
var ze = De, Be = ze, we = /^\s+/;
function Pe(t) {
  return t && t.slice(0, Be(t) + 1).replace(we, "");
}
var Ee = Pe, Me = te, Ne = Me.Symbol, ne = Ne, J = ne, ae = Object.prototype, Ae = ae.hasOwnProperty, Le = ae.toString, O = J ? J.toStringTag : void 0;
function Re(t) {
  var a = Ae.call(t, O), n = t[O];
  try {
    t[O] = void 0;
    var d = !0;
  } catch {
  }
  var u = Le.call(t);
  return d && (a ? t[O] = n : delete t[O]), u;
}
var Fe = Re, Ge = Object.prototype, Ve = Ge.toString;
function We(t) {
  return Ve.call(t);
}
var Ke = We, Q = ne, Ue = Fe, He = Ke, Xe = "[object Null]", qe = "[object Undefined]", Y = Q ? Q.toStringTag : void 0;
function Je(t) {
  return t == null ? t === void 0 ? qe : Xe : Y && Y in Object(t) ? Ue(t) : He(t);
}
var Qe = Je;
function Ye(t) {
  return t != null && typeof t == "object";
}
var Ze = Ye, _e = Qe, xe = Ze, et = "[object Symbol]";
function tt(t) {
  return typeof t == "symbol" || xe(t) && _e(t) == et;
}
var nt = tt, at = Ee, Z = ee, it = nt, _ = NaN, rt = /^[-+]0x[0-9a-f]+$/i, ot = /^0b[01]+$/i, lt = /^0o[0-7]+$/i, st = parseInt;
function ut(t) {
  if (typeof t == "number")
    return t;
  if (it(t))
    return _;
  if (Z(t)) {
    var a = typeof t.valueOf == "function" ? t.valueOf() : t;
    t = Z(a) ? a + "" : a;
  }
  if (typeof t != "string")
    return t === 0 ? t : +t;
  t = at(t);
  var n = ot.test(t);
  return n || lt.test(t) ? st(t.slice(2), n ? 2 : 8) : rt.test(t) ? _ : +t;
}
var dt = ut, ft = ee, R = Ie, x = dt, bt = "Expected a function", ct = Math.max, mt = Math.min;
function pt(t, a, n) {
  var d, u, b, m, r, p, k = 0, D = !1, T = !1, j = !0;
  if (typeof t != "function")
    throw new TypeError(bt);
  a = x(a) || 0, ft(n) && (D = !!n.leading, T = "maxWait" in n, b = T ? ct(x(n.maxWait) || 0, a) : b, j = "trailing" in n ? !!n.trailing : j);
  function C(o) {
    var v = d, S = u;
    return d = u = void 0, k = o, m = t.apply(S, v), m;
  }
  function z(o) {
    return k = o, r = setTimeout(i, a), D ? C(o) : m;
  }
  function e(o) {
    var v = o - p, S = o - k, V = a - v;
    return T ? mt(V, b - S) : V;
  }
  function c(o) {
    var v = o - p, S = o - k;
    return p === void 0 || v >= a || v < 0 || T && S >= b;
  }
  function i() {
    var o = R();
    if (c(o))
      return G(o);
    r = setTimeout(i, e(o));
  }
  function G(o) {
    return r = void 0, j && d ? C(o) : (d = u = void 0, m);
  }
  function ie() {
    r !== void 0 && clearTimeout(r), k = 0, d = p = u = r = void 0;
  }
  function re() {
    return r === void 0 ? m : G(R());
  }
  function M() {
    var o = R(), v = c(o);
    if (d = arguments, u = this, p = o, v) {
      if (r === void 0)
        return z(p);
      if (T)
        return clearTimeout(r), r = setTimeout(i, a), C(p);
    }
    return r === void 0 && (r = setTimeout(i, a)), m;
  }
  return M.cancel = ie, M.flush = re, M;
}
var yt = pt;
const F = /* @__PURE__ */ ge(yt), gt = { class: "das-ui-button" }, vt = {
  inheritAttrs: !1
  // 不希望组件的根元素继承特性
}, kt = /* @__PURE__ */ le({
  ...vt,
  __name: "Index",
  props: {
    btnType: {},
    size: { default: "middle" },
    disabled: { type: Boolean, default: !1 },
    block: { type: Boolean, default: !1 },
    ghost: { type: Boolean, default: !1 },
    menuData: { default: [] },
    defaultMenuProps: { default: () => ({
      key: "key",
      label: "label",
      icon: "icon"
    }) },
    icon: { default: "" },
    activeIcon: { default: "" },
    isIconLeft: { type: Boolean, default: !0 },
    trigger: { default: "click" },
    activeKey: { type: [String, Number, Boolean], default: "" },
    getPopupContainer: { type: Function, default: (t) => t.parentNode || document.body },
    isClickDebounce: { type: Boolean, default: !0 }
  },
  emits: ["update:activeKey", "click"],
  setup(t, { emit: a }) {
    fe({
      fold: import("@das-fed/ui/packages/icons/fold"),
      unflod: import("@das-fed/ui/packages/icons/unflod")
    });
    const n = t, d = a;
    let u = W(n.activeKey), b = W(n.icon);
    const m = se(() => n.size === "small" ? "mini" : n.size === "middle" ? "small" : n.size === "large" ? "medium" : "small");
    ue(() => {
      d("update:activeKey", u.value);
    });
    const r = (e, c) => {
      document.body.click(), d("click", e, c);
    }, p = F(
      (e) => {
        b.value = n.icon, r(e, "menu-click");
      },
      300,
      {
        leading: !0
      }
    ), k = F(
      (e) => {
        r(e, "button-click");
      },
      300,
      {
        leading: !0
      }
    ), D = F(
      (e) => {
        r(e, "self");
      },
      300,
      {
        leading: !0
      }
    ), T = (e) => {
      n.isClickDebounce ? D(e) : r(e, "self");
    }, j = (e) => {
      n.isClickDebounce ? k(e) : r(e, "button-click");
    }, C = (e) => {
      n.isClickDebounce ? p(e) : (b.value = n.icon, r(e, "menu-click"));
    }, z = (e) => {
      e ? b.value = n.activeIcon ? n.activeIcon : n.icon : b.value = n.icon;
    };
    return (e, c) => (s(), h("div", gt, [
      y(" 同类集合按钮 "),
      e.btnType === "default-sameset" || e.btnType === "primary-sameset" ? (s(), g(l(be), B({ key: 0 }, e.$attrs, {
        tabindex: "-1",
        trigger: e.trigger,
        disabled: e.disabled,
        getPopupContainer: e.getPopupContainer,
        onVisibleChange: z,
        overlayClassName: "sameset-dropdown-wrap",
        onClick: j,
        type: e.btnType === "primary-sameset" ? "primary" : "default",
        class: `${e.block ? "block" : ""} ${e.size}`
      }), K({
        icon: f(() => [
          e.icon ? (s(), g(l(P), {
            key: 0,
            icon: l(b),
            size: m.value
          }, null, 8, ["icon", "size"])) : y("v-if", !0)
        ]),
        default: f(() => [
          w(e.$slots, "default", {}, void 0, !0),
          c[1] || (c[1] = U(
            "span",
            null,
            null,
            -1
            /* HOISTED */
          ))
        ]),
        _: 2
        /* DYNAMIC */
      }, [
        e.menuData && e.menuData.length > 0 ? {
          name: "overlay",
          fn: f(() => [
            I(l(H), { onClick: C }, {
              default: f(() => [
                (s(!0), h(
                  $,
                  null,
                  N(e.menuData, (i) => (s(), g(l(X), {
                    key: i[e.defaultMenuProps.key],
                    disabled: i.disabled
                  }, {
                    default: f(() => [
                      A(
                        L(i[e.defaultMenuProps.label]),
                        1
                        /* TEXT */
                      )
                    ]),
                    _: 2
                    /* DYNAMIC */
                  }, 1032, ["disabled"]))),
                  128
                  /* KEYED_FRAGMENT */
                ))
              ]),
              _: 1
              /* STABLE */
            })
          ]),
          key: "0"
        } : void 0
      ]), 1040, ["trigger", "disabled", "getPopupContainer", "type", "class"])) : e.btnType === "default-basicset" || e.btnType === "primary-basicset" ? (s(), h(
        $,
        { key: 1 },
        [
          y(" 基础集合按钮 "),
          I(l(ce), B(e.$attrs, {
            tabindex: "-1",
            type: e.btnType === "primary-basicset" ? "primary" : "default",
            trigger: e.trigger,
            disabled: e.disabled,
            ref: "basicsetDropdownRef",
            class: `${e.block ? "block" : ""} ${e.btnType === "primary-basicset" ? "primary" : "default"} ${e.size}`,
            onVisibleChange: z,
            overlayClassName: "basicset-dropdown-wrap"
          }), K({
            default: f(() => [
              I(l(q), null, {
                default: f(() => [
                  w(e.$slots, "default", {}, void 0, !0),
                  e.icon ? (s(), g(l(P), {
                    key: 0,
                    icon: l(b),
                    size: e.size === "small" ? "medium" : e.size === "middle" ? "big" : e.size === "large" ? "large" : "big"
                  }, null, 8, ["icon", "size"])) : y("v-if", !0)
                ]),
                _: 3
                /* FORWARDED */
              })
            ]),
            _: 2
            /* DYNAMIC */
          }, [
            e.menuData && e.menuData.length > 0 ? {
              name: "overlay",
              fn: f(() => [
                I(l(H), { onClick: C }, {
                  default: f(() => [
                    (s(!0), h(
                      $,
                      null,
                      N(e.menuData, (i) => (s(), g(l(X), {
                        key: i[e.defaultMenuProps.key],
                        disabled: i.disabled
                      }, {
                        default: f(() => [
                          w(e.$slots, "menu-item", { item: i }, () => [
                            A(
                              L(i[e.defaultMenuProps.label]),
                              1
                              /* TEXT */
                            )
                          ], !0)
                        ]),
                        _: 2
                        /* DYNAMIC */
                      }, 1032, ["disabled"]))),
                      128
                      /* KEYED_FRAGMENT */
                    ))
                  ]),
                  _: 3
                  /* FORWARDED */
                })
              ]),
              key: "0"
            } : void 0
          ]), 1040, ["type", "trigger", "disabled", "class"])
        ],
        64
        /* STABLE_FRAGMENT */
      )) : e.btnType === "tabs" ? (s(), h(
        $,
        { key: 2 },
        [
          y(" 切换按钮tab "),
          e.menuData && e.menuData.length > 0 ? (s(), g(l(me), B({ key: 0 }, e.$attrs, {
            tabindex: "-1",
            disabled: e.disabled,
            value: l(u),
            "onUpdate:value": c[0] || (c[0] = (i) => de(u) ? u.value = i : u = i)
          }), {
            default: f(() => [
              (s(!0), h(
                $,
                null,
                N(e.menuData, (i) => (s(), g(l(pe), {
                  key: i[e.defaultMenuProps.key],
                  value: i[e.defaultMenuProps.key],
                  disabled: i.disabled
                }, {
                  default: f(() => [
                    A(
                      L(i[e.defaultMenuProps.label]),
                      1
                      /* TEXT */
                    )
                  ]),
                  _: 2
                  /* DYNAMIC */
                }, 1032, ["value", "disabled"]))),
                128
                /* KEYED_FRAGMENT */
              ))
            ]),
            _: 1
            /* STABLE */
          }, 16, ["disabled", "value"])) : y("v-if", !0)
        ],
        64
        /* STABLE_FRAGMENT */
      )) : (s(), h(
        $,
        { key: 3 },
        [
          y(" 普通按钮 "),
          I(l(q), B(e.$attrs, {
            tabindex: "-1",
            class: [
              e.size,
              {
                "primary-text": e.btnType === "primary-text",
                "default-text": e.btnType === "default-text",
                "icon-btn": e.icon,
                "icon-rigt": e.icon && !e.isIconLeft
              }
            ],
            type: e.btnType && ["primary-text", "default-text"].includes(e.btnType) ? "text" : e.btnType,
            size: e.size,
            disabled: e.disabled,
            block: e.block,
            ghost: e.ghost,
            onClick: T
          }), {
            default: f(() => [
              e.icon && e.isIconLeft ? (s(), g(l(P), {
                key: 0,
                icon: e.icon,
                size: m.value
              }, null, 8, ["icon", "size"])) : y("v-if", !0),
              w(e.$slots, "default", {}, void 0, !0),
              c[2] || (c[2] = U(
                "a",
                null,
                null,
                -1
                /* HOISTED */
              )),
              e.icon && !e.isIconLeft ? (s(), g(l(P), {
                key: 1,
                icon: e.icon,
                size: m.value
              }, null, 8, ["icon", "size"])) : y("v-if", !0)
            ]),
            _: 3
            /* FORWARDED */
          }, 16, ["class", "type", "size", "disabled", "block", "ghost"])
        ],
        64
        /* STABLE_FRAGMENT */
      ))
    ]));
  }
}), Tt = (t, a) => {
  const n = t.__vccOpts || t;
  for (const [d, u] of a)
    n[d] = u;
  return n;
}, ht = /* @__PURE__ */ Tt(kt, [["__scopeId", "data-v-6fd62293"]]), Ct = {
  "--demo-alert-bg": {
    light: "#fff",
    dark: "rgba(255,255,255,.2)"
  },
  "--das-ui-button-primary": "#5582F3",
  "--das-ui-button-primary-text": "#fff",
  "--das-ui-button-primary-text-disabled": "rgba(255,255,255,.8)",
  "--das-ui-button-default-text": "#212121",
  "--das-ui-button-default-border": "#d9d9d9",
  "--das-ui-button-default-disabled": "#b2b2b2",
  "--das-ui-button-default-disabled-bgc": "#f5f5f5",
  "--das-ui-button-primary-hover": "#87A9FF ",
  "--das-ui-button-active": "#3761CA ",
  "--das-ui-button-disabled": "#B5CAFF",
  "--das-ui-button-set": "#4367C1",
  "--das-ui-button-set-hover": "#4C74DA",
  "--das-ui-button-set-active": "#3B5AA9",
  "--das-ui-button-set-disabled": "#95A4C8"
};
ye(Ct);
const wt = oe(ht);
export {
  wt as DasButton,
  wt as default
};
