import { objectWithoutProperties as _objectWithoutProperties, extends as _extends } from '../../../_virtual/_rollupPluginBabelHelpers.js';
import React__default, { forwardRef } from 'react';
import { cx } from '../../../utils/index.js';
import { base as base$1 } from './variations/_view/base.js';
import { base as base$2 } from './variations/_size/base.js';
import { base as base$3 } from './variations/_disabled/base.js';
import { LoadWrap, IconContainer, Loader, StyledSpinner, base } from './EmbeddedButton.styles.js';
import { classes } from './EmbeddedButton.tokens.js';

var _StyledSpinner;
var _excluded = ["children", "view", "size", "disabled", "isLoading", "loader", "position", "className"];
var embeddedButtonRoot = function embeddedButtonRoot(Root) {
  return /*#__PURE__*/forwardRef(function (props, ref) {
    var children = props.children,
      view = props.view,
      size = props.size,
      disabled = props.disabled,
      isLoading = props.isLoading,
      loader = props.loader,
      _props$position = props.position,
      position = _props$position === void 0 ? 'center' : _props$position,
      className = props.className,
      rest = _objectWithoutProperties(props, _excluded);
    var isLoadingClass = isLoading ? classes.embeddedButtonLoading : undefined;
    return /*#__PURE__*/React__default.createElement(Root, _extends({
      type: "button",
      ref: ref,
      view: view,
      size: size,
      disabled: disabled,
      className: cx(isLoadingClass, className)
    }, rest), /*#__PURE__*/React__default.createElement(LoadWrap, {
      position: position,
      isLoading: isLoading
    }, /*#__PURE__*/React__default.createElement(IconContainer, null, children)), isLoading && /*#__PURE__*/React__default.createElement(Loader, null, loader || _StyledSpinner || (_StyledSpinner = /*#__PURE__*/React__default.createElement(StyledSpinner, null))));
  });
};
var embeddedButtonConfig = {
  name: 'EmbeddedButton',
  tag: 'button',
  layout: embeddedButtonRoot,
  base: base,
  variations: {
    view: {
      css: base$1
    },
    size: {
      css: base$2
    },
    disabled: {
      css: base$3,
      attrs: true
    }
  },
  defaults: {
    view: 'secondary',
    size: 'm'
  }
};

export { embeddedButtonConfig, embeddedButtonRoot };
