import { objectWithoutProperties as _objectWithoutProperties, objectSpread2 as _objectSpread2, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
import React__default, { forwardRef } from 'react';
import { base as base$2 } from './variations/_view/base.js';
import { base as base$1 } from './variations/_size/base.js';
import { SpinnerSvg } from './SpinnerSvg.js';
import { SpinnerWrapper, base } from './Spinner.styles.js';
import { useInnerProps } from './hooks/index.js';
import { safeUseId } from '../../utils/react.js';

var _excluded = ["id", "width", "height", "style"];
var spinnerRoot = function spinnerRoot(Root) {
  return /*#__PURE__*/forwardRef(function (props, ref) {
    var id = props.id,
      width = props.width,
      height = props.height,
      style = props.style,
      rest = _objectWithoutProperties(props, _excluded);
    var innerProps = useInnerProps(props, {
      wrapperWidth: 'auto',
      wrapperHeight: 'auto',
      svgWidth: 'var(--plasma-spinner-size)',
      svgHeight: 'var(--plasma-spinner-size)',
      color: 'currentColor'
    });
    var uniqId = safeUseId;
    var innerId = id || uniqId();
    var rootStyle = width && height ? _objectSpread2(_objectSpread2({}, style), {}, {
      width: innerProps.wrapperWidth,
      height: innerProps.wrapperHeight
    }) : style;
    return /*#__PURE__*/React__default.createElement(Root, _extends({
      ref: ref,
      id: innerId
    }, rest, {
      style: rootStyle
    }), /*#__PURE__*/React__default.createElement(SpinnerWrapper, {
      width: innerProps.wrapperWidth,
      height: innerProps.wrapperHeight
    }, /*#__PURE__*/React__default.createElement(SpinnerSvg, {
      id: innerId,
      width: innerProps.svgWidth,
      height: innerProps.svgHeight,
      color: innerProps.color
    })));
  });
};
var spinnerConfig = {
  name: 'Spinner',
  tag: 'div',
  layout: spinnerRoot,
  base: base,
  variations: {
    size: {
      css: base$1
    },
    view: {
      css: base$2
    }
  },
  defaults: {
    size: 'm',
    view: 'accent'
  }
};

export { spinnerConfig, spinnerRoot };
