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; }

import React from 'react';
import cx from 'classnames';
import { Illustration } from '../Illustration';

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 = cx('content', center && 'center', contentMiddle && 'middle');
    if (!stack && !!illustration) return /*#__PURE__*/React.createElement(React.Fragment, null);
    return /*#__PURE__*/React.createElement("div", {
      className: contentClasses
    }, /*#__PURE__*/React.createElement("div", {
      className: "inner"
    }, children));
  };

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

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

  var halfClasses = cx('half', stack && 'stack');
  return /*#__PURE__*/React.createElement("div", _extends({
    className: halfClasses
  }, rest), /*#__PURE__*/React.createElement(Photo, null), /*#__PURE__*/React.createElement(ShowIllustration, null), /*#__PURE__*/React.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;
export { HalfWrapper as Half };