"use strict";

exports.__esModule = true;
exports.Half = void 0;

var _react = _interopRequireDefault(require("react"));

var _classnames = _interopRequireDefault(require("classnames"));

var _Illustration = require("../Illustration");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }

var Half = function Half(_ref) {
  var _ref$center = _ref.center,
      center = _ref$center === void 0 ? false : _ref$center,
      illustration = _ref.illustration,
      _ref$illustrationMidd = _ref.illustrationMiddle,
      illustrationMiddle = _ref$illustrationMidd === void 0 ? false : _ref$illustrationMidd,
      photo = _ref.photo,
      _ref$photoMiddle = _ref.photoMiddle,
      photoMiddle = _ref$photoMiddle === void 0 ? false : _ref$photoMiddle,
      _ref$stack = _ref.stack,
      stack = _ref$stack === void 0 ? false : _ref$stack,
      _ref$contentMiddle = _ref.contentMiddle,
      contentMiddle = _ref$contentMiddle === void 0 ? false : _ref$contentMiddle,
      children = _ref.children,
      rest = _objectWithoutPropertiesLoose(_ref, ["center", "illustration", "illustrationMiddle", "photo", "photoMiddle", "stack", "contentMiddle", "children"]);

  var Content = function Content() {
    var contentClasses = (0, _classnames.default)('content', center && 'center', contentMiddle && 'middle');
    if (!stack && !!illustration) return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null);
    return /*#__PURE__*/_react.default.createElement("div", {
      className: contentClasses
    }, /*#__PURE__*/_react.default.createElement("div", {
      className: "inner"
    }, children));
  };

  var ShowIllustration = function ShowIllustration() {
    var illustrationClasses = (0, _classnames.default)('illustration', illustrationMiddle && 'middle');
    if (!illustration) return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null);
    if (!stack && !illustration) return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null);
    return /*#__PURE__*/_react.default.createElement(_Illustration.Illustration, {
      className: illustrationClasses,
      src: illustration
    });
  };

  var Photo = function Photo() {
    var photoClasses = (0, _classnames.default)('photo', photoMiddle && 'middle');
    if (!photo) return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null);
    if (!stack && !photo) return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null);
    return /*#__PURE__*/_react.default.createElement("div", {
      className: photoClasses
    }, /*#__PURE__*/_react.default.createElement("img", {
      src: photo,
      alt: ""
    }));
  };

  var halfClasses = (0, _classnames.default)('half', stack && 'stack');
  return /*#__PURE__*/_react.default.createElement("div", _extends({
    className: halfClasses
  }, rest), /*#__PURE__*/_react.default.createElement(Photo, null), /*#__PURE__*/_react.default.createElement(ShowIllustration, null), /*#__PURE__*/_react.default.createElement(Content, null));
};

Half.displayName = 'Half';
var HalfDoc;

if (process.env.NODE_ENV !== 'production') {
  // eslint-disable-next-line global-require
  HalfDoc = require('./doc').doc(Half);
}

var HalfWrapper = HalfDoc || Half;
exports.Half = HalfWrapper;