text: "use strict";
  
  exports.__esModule = true;
  exports.default = AppLoader;
  
  var _propTypes = _interopRequireDefault(require("prop-types"));
  
  var _react = _interopRequireDefault(require("react"));
  
  var _useStyles = _interopRequireDefault(require("../../hooks/useStyles"));
  
  var _ErrorMessage = _interopRequireDefault(require("../ErrorMessage"));
  
  var _Loader = _interopRequireDefault(require("../Loader"));
  
  var _Title = _interopRequireDefault(require("../Title"));
  
  var _Text = _interopRequireDefault(require("../Text"));
  
  var _styles = require("./styles");
  
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  
  /** A loading indicator, representing the state of a request, for applications and landing pages. */
  function AppLoader(_ref) {
    let {
      centered,
      children,
      error,
      errorTitle,
      failureText,
      fetched,
      loadingText,
      small,
      subtitle
    } = _ref;
    const [styles, cx] = (0, _useStyles.default)(_styles.styleSheet);
  
    if (fetched && !error) {
      return _react.default.createElement("main", null, children);
    }
  
    return _react.default.createElement("div", {
      className: cx(styles.appLoader, centered && styles.appLoader_centered)
    }, _react.default.createElement(_Title.default, {
      level: small ? 3 : 1
    }, error ? failureText : loadingText), subtitle && _react.default.createElement("div", {
      className: cx(styles.subtitle)
    }, _react.default.createElement(_Text.default, {
      large: !small
    }, subtitle)), _react.default.createElement("div", {
      className: cx(styles.errorOrLoader)
    }, error ? _react.default.createElement(_ErrorMessage.default, {
      error: error,
      title: errorTitle
    }) : _react.default.createElement(_Loader.default, {
      inline: true
    })));
  }
  
  AppLoader.propTypes = {
    centered: _propTypes.default.bool,
    children: _propTypes.default.any.isRequired,
    error: _propTypes.default.oneOfType([_propTypes.default.any, _propTypes.default.oneOf([null])]),
    errorTitle: _propTypes.default.node,
    failureText: _propTypes.default.any.isRequired,
    fetched: _propTypes.default.bool,
    loadingText: _propTypes.default.any.isRequired,
    small: _propTypes.default.bool,
    subtitle: _propTypes.default.node
  };