"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const jsxRuntime = require("react/jsx-runtime");
const React = require("react");
const classNames = require("../../utils/classNames.cjs");
const config_context = require("../config/config.context.cjs");
const spinner_component = require("../spinner/spinner.component.cjs");
require("./button.theme.css.cjs");
function _interopNamespaceDefault(e) {
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
  if (e) {
    for (const k in e) {
      if (k !== "default") {
        const d = Object.getOwnPropertyDescriptor(e, k);
        Object.defineProperty(n, k, d.get ? d : {
          enumerable: true,
          get: () => e[k]
        });
      }
    }
  }
  n.default = e;
  return Object.freeze(n);
}
const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
const Button = React__namespace.forwardRef((props, ref) => {
  const { className, disabled, displayStyle, displaySize, displayStatus, pending, pendingPosition, disableOnPending, leftOverlay, rightOverlay, children, ...nativeProps } = props;
  const globals = config_context.useArmstrongConfig({
    buttonDisplaySize: displaySize,
    buttonDisplayStyle: displayStyle,
    buttonPendingPosition: pendingPosition,
    disableControlOnPending: disableOnPending
  });
  const spinner = jsxRuntime.jsx(spinner_component.Spinner, { className: classNames.concat("arm-button-spinner", `arm-button-${pendingPosition}-icon`), role: "status" });
  const wrappedLeftIcon = leftOverlay && jsxRuntime.jsx("span", { className: "arm-button-left-icon", children: leftOverlay });
  const wrappedRightIcon = rightOverlay && jsxRuntime.jsx("span", { className: "arm-button-right-icon", children: rightOverlay });
  return jsxRuntime.jsxs("button", { className: classNames.concat("arm-button", className), "data-pending": pending, "data-disabled": disabled || globals.disableControlOnPending && pending, "data-size": globals.buttonDisplaySize, "data-style": globals.buttonDisplayStyle, "data-status": displayStatus, disabled: disabled || pending, tabIndex: disabled ? -1 : nativeProps.tabIndex, ref, ...nativeProps, children: [pending && globals.buttonPendingPosition === "left" ? spinner : wrappedLeftIcon, jsxRuntime.jsx("span", { className: "arm-button-contents", children }), pending && globals.buttonPendingPosition === "right" ? spinner : wrappedRightIcon] });
});
Button.defaultProps = {
  pendingPosition: "right"
};
Button.displayName = "Button";
exports.Button = Button;
//# sourceMappingURL=button.component.cjs.map
