"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.Spinner = void 0;

var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));

var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));

var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));

var _react = require("@emotion/react");

var _react2 = _interopRequireWildcard(require("react"));

var _Box = require("../Box");

var _VisuallyHidden = require("../VisuallyHidden");

var _styles = _interopRequireDefault(require("./styles"));

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

var __jsx = _react2["default"].createElement;

function _templateObject() {
  var data = (0, _taggedTemplateLiteral2["default"])(["\n  0% {\n    transform: rotate(0deg);\n  }\n  100% {\n    transform: rotate(360deg);\n  }\n"]);

  _templateObject = function _templateObject() {
    return data;
  };

  return data;
}

var spin = (0, _react.keyframes)(_templateObject());
/**
 * Spinner is used for indicating a loading state of a component or page.
 *
 * RECOMMENDED: Add `aria-busy="true"` to the component that triggered the loading state while the spinner is shown.
 */

var Spinner = /*#__PURE__*/(0, _react2.forwardRef)(function (_ref, ref) {
  var _ref$size = _ref.size,
      size = _ref$size === void 0 ? 'sm' : _ref$size,
      _ref$label = _ref.label,
      label = _ref$label === void 0 ? 'Loading...' : _ref$label,
      thickness = _ref.thickness,
      _ref$speed = _ref.speed,
      speed = _ref$speed === void 0 ? '0.5s' : _ref$speed,
      color = _ref.color,
      emptyColor = _ref.emptyColor,
      props = (0, _objectWithoutProperties2["default"])(_ref, ["size", "label", "thickness", "speed", "color", "emptyColor"]);
  var spinnerStyleProps = (0, _styles["default"])({
    size: size,
    thickness: thickness,
    color: color,
    emptyColor: emptyColor
  });
  return __jsx(_Box.Box, (0, _extends2["default"])({
    ref: ref,
    display: "inline-block",
    animation: "".concat(spin, " ").concat(speed, " linear infinite")
  }, spinnerStyleProps, props), label && __jsx(_VisuallyHidden.VisuallyHidden, null, label));
});
exports.Spinner = Spinner;
//# sourceMappingURL=Spinner.js.map