import { jsxs as j, jsx as B } from "react/jsx-runtime";
import { useButton as I } from "@react-aria/button";
import { useFocusRing as O } from "@react-aria/focus";
import { forwardRef as V, cloneElement as _ } from "react";
import { buttonTypeMap as k, buttonIconSizeMap as z } from "./mappings.es.js";
import { FOCUS_VISIBLE_STYLE as T } from "../../utilities/focusStyle.es.js";
import { merge as r } from "../../utilities/merge.es.js";
import { useForwardedRef as U } from "../../utilities/useForwardedRef.es.js";
import { ButtonCommonClasses as W, ButtonRoundingClasses as Y, ButtonSizeClasses as d, IconSpacingClasses as q, ButtonStyleClasses as v, ButtonDisabledClasses as A } from "./ButtonClasses.es.js";
import { ButtonStyle as o, ButtonEmphasis as u, ButtonType as G, ButtonSize as H, ButtonRounding as J } from "./ButtonTypes.es.js";
const K = ({
  type: S = G.Button,
  title: b = "",
  style: t = o.Default,
  size: s = H.Medium,
  rounding: y = J.Medium,
  emphasis: n = u.Strong,
  hideLabel: i = !1,
  disabled: e = !1,
  icon: m,
  children: a,
  onClick: p,
  hugWidth: C = !0,
  "aria-label": g,
  "aria-describedby": w,
  formId: D,
  solid: x,
  inverted: F,
  "data-test-id": f = "button"
}, N) => {
  t === o.Primary ? (t = o.Default, n = u.Strong) : t === o.Secondary && (t = o.Default, n = u.Default), x === !1 && (n = u.Weak);
  const c = U(N), { buttonProps: R } = I(
    { onPress: () => p && p(), isDisabled: e, type: k[S] },
    c
  ), { isFocusVisible: E, focusProps: M } = O(), l = ($) => e ? A : `${v[n][t][$]}`, P = r([
    l("button"),
    W,
    Y[y],
    m && !a || i ? d[s].iconOnly : d[s].default,
    !C && "tw-w-full"
  ]);
  return /* @__PURE__ */ j(
    "button",
    {
      "data-test-id": f,
      "aria-label": g,
      "aria-disabled": e,
      "aria-describedby": w,
      ref: c,
      className: r([P, F && "tw-dark", E && T]),
      disabled: e,
      form: D,
      title: b,
      ...R,
      ...M,
      children: [
        m && /* @__PURE__ */ B(
          "span",
          {
            "data-test-id": `${f}-icon`,
            className: r([a && !i ? q[s] : "", l("icon")]),
            children: _(m, { size: z[s] })
          }
        ),
        a && /* @__PURE__ */ B(
          "span",
          {
            "data-test-id": `${f}-text`,
            className: r([l("text"), i && "tw-sr-only"]),
            children: a
          }
        )
      ]
    }
  );
}, L = V(K);
L.displayName = "FondueButton";
export {
  L as Button
};
//# sourceMappingURL=Button.es.js.map
