import { jsxs as E, jsx as k } from "react/jsx-runtime";
import { forwardRef as $, useState as S, useRef as w } from "react";
import { noop as B } from "es-toolkit/function";
import F from "../../utils/classNames.js";
import { createButtonRipple as L } from "../../utils/buttonEffect.js";
import G from "../../hooks/useMergeRefs.js";
import { getAutoTrackingAttributes as z } from "../../utils/analytics/autoTracking.js";
const W = {
  DEFAULT: "default",
  UNSTYLED: "unstyled",
  PRIMARY: "primary",
  SECONDARY: "secondary",
  INFO: "info",
  WARNING: "warning",
  DANGER: "danger",
  SUCCESS: "success",
  MUTED: "muted",
  MUTED_FILLED: "muted-filled"
}, s = {
  VARIANT_LINK: "link",
  VARIANT_LINK_INLINE: "link-inline",
  VARIANT_OUTLINE: "outline",
  VARIANT_ACTION: "action"
}, X = {
  XS: "xs",
  SM: "sm",
  MD: "md",
  LG: "lg"
}, u = $((_, h) => {
  const {
    as: a = "button",
    active: e = !1,
    disabled: n = !1,
    asToggle: f = !1,
    onClick: l = B,
    bsStyle: C = "default",
    bsSize: b,
    variant: i,
    iconOnly: v = !1,
    iconName: o,
    iconRight: y = !1,
    multiline: O = !1,
    block: D = !1,
    hoverScale: M = !1,
    className: V = "",
    noRippleEffect: N = !1,
    autoTrackingKey: U,
    type: x = "button",
    tabIndex: A = 0,
    children: m,
    ...r
  } = _, I = z({
    autoTrackingKey: U,
    props: r,
    source: "button"
  }), [g, d] = S(e), T = w(null), p = G(T, h), [P, j] = S(e);
  e !== P && (d(e), j(e));
  const K = (t) => {
    if (N || L(t.nativeEvent, t.currentTarget), f) {
      const c = !g;
      d(c), c && T.current?.blur(), l(c);
    } else
      l(t);
  }, Y = (t) => {
    if (n) {
      t.preventDefault();
      return;
    }
    N || L(t.nativeEvent, t.currentTarget), l(t);
  }, R = F(
    "btn",
    `btn-${C}`,
    i === s.VARIANT_LINK && "btn-link",
    i === s.VARIANT_LINK_INLINE && "btn-link btn-link-inline",
    i === s.VARIANT_OUTLINE && "btn-outline",
    i === s.VARIANT_ACTION && "btn-action",
    b && `btn-${b}`,
    f && "btn-toggle",
    g && "active",
    v && "btn-icon-only",
    y && "btn-icon-right",
    O && "btn-multiline",
    D && "btn-block",
    M && "hover-scale",
    a === "a" && "gap-0",
    a === "a" && n && "disabled",
    "btn-component",
    V
  );
  return a === "a" ? /* @__PURE__ */ E(
    "a",
    {
      ref: p,
      ...r,
      ...I,
      className: R,
      onClick: Y,
      "aria-disabled": n || void 0,
      tabIndex: n ? -1 : A,
      children: [
        o && /* @__PURE__ */ k("span", { className: `rioglyph ${o}` }),
        m
      ]
    }
  ) : /* @__PURE__ */ E(
    "button",
    {
      ref: p,
      type: x,
      ...r,
      ...I,
      className: R,
      onClick: K,
      disabled: n,
      tabIndex: A,
      children: [
        o && /* @__PURE__ */ k("span", { className: `rioglyph ${o}` }),
        m
      ]
    }
  );
});
Object.assign(u, W);
Object.assign(u, s);
Object.assign(u, X);
export {
  X as SIZES_MAP,
  W as STYLES_MAP,
  s as VARIANTS_MAP,
  u as default
};
//# sourceMappingURL=Button.js.map
