/* action-button.tsx generated by @compiled/babel-plugin v0.39.1 */
import _extends from "@babel/runtime/helpers/extends";
import "./action-button.compiled.css";
import * as React from 'react';
import { ax, ix } from "@compiled/react/runtime";
import { useCallback } from 'react';
import { cx } from '@atlaskit/css';
import { fg } from '@atlaskit/platform-feature-flags';
import { Box, Inline, Pressable } from '@atlaskit/primitives/compiled';
import Spinner from '@atlaskit/spinner';
import { getPrimitivesInlineSpaceBySize } from '../../../utils';
import ActionIcon from '../action-icon';
const styles = {
  button: "_bfhksm61 _ca0q1b66 _u5f31b66 _n3td1b66 _19bv1b66 _1bsb1osq _1ah31i6y _irr31dpa _1di6fcek",
  content: "_11c8wadc _syazi7uo",
  spinner: "_1bsb1tcg _4t3i1tcg _1e0c116y _4cvr1h6o _1bah1h6o"
};
const ActionButton = ({
  content,
  icon: iconOption,
  isDisabled,
  isLoading,
  onClick: onClickCallback,
  size,
  space: spaceOption,
  testId,
  tooltipProps,
  style,
  ariaLabel
}) => {
  const space = spaceOption !== null && spaceOption !== void 0 ? spaceOption : getPrimitivesInlineSpaceBySize(size);
  const onClick = useCallback(() => {
    if (!isDisabled && !isLoading && onClickCallback) {
      onClickCallback();
    }
  }, [isDisabled, isLoading, onClickCallback]);

  // FIX-ME: This is required for ResolvedHoverCardFooterBlock action to show proper size
  // ResolvedHoverCardFooterBlock is currently not used but keeping inside the code base for
  // upcoming experiment to refresh HoverCard design
  // If ResolvedHoverCardFooterBlock is cleaned up, this code can be removed.
  const showSpinnerSize24 = false;
  const icon = iconOption && isLoading ? /*#__PURE__*/React.createElement(ActionIcon, {
    icon: showSpinnerSize24 ? /*#__PURE__*/React.createElement(Box, {
      xcss: styles.spinner
    }, /*#__PURE__*/React.createElement(Spinner, {
      size: 16,
      testId: `${testId}-loading`
    })) : /*#__PURE__*/React.createElement(Spinner, {
      testId: `${testId}-loading`
    })
  }) : iconOption;
  return /*#__PURE__*/React.createElement(Pressable, _extends({
    xcss: cx(styles.button)
  }, tooltipProps, {
    onClick: onClick,
    testId: testId
    // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
    ,
    style: style
  }, fg('platform_sl_action_refactoring') ? {
    'aria-label': ariaLabel
  } : {}), /*#__PURE__*/React.createElement(Inline, {
    alignBlock: "center",
    grow: "fill",
    space: space
  }, icon, /*#__PURE__*/React.createElement(Box, {
    xcss: cx(styles.content)
  }, content)));
};
export default ActionButton;