import { objectWithoutProperties as _objectWithoutProperties, extends as _extends } from '../../../_virtual/_rollupPluginBabelHelpers.js';
import React__default, { forwardRef } from 'react';
import { base as base$1 } from './variations/_view/base.js';
import { base as base$2 } from './variations/_size/base.js';
import { base, Title, ContentWrapper, FooterWrapper, LoadingWrapper, SpinnerUI, LoadingTitle, ErrorContainer, ErrorTitle, ErrorTextContent } from './Answer.styles.js';

var _SpinnerUI;
var _excluded = ["title", "content", "footer", "isLoading", "loaderTitle", "customLoader", "isError", "errorTitle", "errorDescription", "customError", "size", "view"];
var answerRoot = function answerRoot(Root) {
  return /*#__PURE__*/forwardRef(function (_ref, ref) {
    var _LoadingTitle, _ErrorTitle, _ErrorTextContent, _Title, _ContentWrapper, _FooterWrapper;
    var title = _ref.title,
      content = _ref.content,
      footer = _ref.footer,
      _ref$isLoading = _ref.isLoading,
      isLoading = _ref$isLoading === void 0 ? false : _ref$isLoading,
      loaderTitle = _ref.loaderTitle,
      customLoader = _ref.customLoader,
      _ref$isError = _ref.isError,
      isError = _ref$isError === void 0 ? false : _ref$isError,
      errorTitle = _ref.errorTitle,
      errorDescription = _ref.errorDescription,
      customError = _ref.customError,
      size = _ref.size,
      view = _ref.view,
      rest = _objectWithoutProperties(_ref, _excluded);
    var renderLoading = function renderLoading() {
      if (customLoader) {
        return customLoader;
      }
      return /*#__PURE__*/React__default.createElement(LoadingWrapper, null, _SpinnerUI || (_SpinnerUI = /*#__PURE__*/React__default.createElement(SpinnerUI, null)), loaderTitle && (_LoadingTitle || (_LoadingTitle = /*#__PURE__*/React__default.createElement(LoadingTitle, null, loaderTitle))));
    };
    var renderError = function renderError() {
      if (customError) {
        return customError;
      }
      return /*#__PURE__*/React__default.createElement(ErrorContainer, null, errorTitle && (_ErrorTitle || (_ErrorTitle = /*#__PURE__*/React__default.createElement(ErrorTitle, null, errorTitle))), errorDescription && (_ErrorTextContent || (_ErrorTextContent = /*#__PURE__*/React__default.createElement(ErrorTextContent, null, errorDescription))));
    };
    var renderContent = function renderContent() {
      if (isLoading) {
        return renderLoading();
      }
      if (isError) {
        return renderError();
      }
      return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, title && (_Title || (_Title = /*#__PURE__*/React__default.createElement(Title, null, title))), content && (_ContentWrapper || (_ContentWrapper = /*#__PURE__*/React__default.createElement(ContentWrapper, null, content))), footer && (_FooterWrapper || (_FooterWrapper = /*#__PURE__*/React__default.createElement(FooterWrapper, null, footer))));
    };
    return /*#__PURE__*/React__default.createElement(Root, _extends({
      ref: ref,
      view: view,
      size: size
    }, rest), renderContent());
  });
};
var answerConfig = {
  name: 'Answer',
  tag: 'div',
  layout: answerRoot,
  base: base,
  variations: {
    view: {
      css: base$1
    },
    size: {
      css: base$2
    }
  },
  defaults: {
    view: 'default',
    size: 'm'
  }
};

export { answerConfig, answerRoot };
