import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
import _createClass from "@babel/runtime/helpers/createClass";
import _inherits from "@babel/runtime/helpers/inherits";
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";

function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }

function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }

import React, { Component } from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';

var SingleComponent = /*#__PURE__*/function (_Component) {
  _inherits(SingleComponent, _Component);

  var _super = _createSuper(SingleComponent);

  function SingleComponent(props) {
    var _this;

    _classCallCheck(this, SingleComponent);

    _this = _super.call(this, props);
    _this.state = {
      height: 0
    };
    return _this;
  }

  _createClass(SingleComponent, [{
    key: "componentDidMount",
    value: function componentDidMount() {
      var height = document.getElementById('container').clientHeight;
      this.setState({
        height: height
      });
    }
  }, {
    key: "render",
    value: function render() {
      var _this$props = this.props,
          centered = _this$props.centered,
          children = _this$props.children,
          flexBasis = _this$props.flexBasis;
      var height = this.state.height;
      var classNames = classnames({
        'wfp--single-component--top': height >= 300,
        'wfp--single-component--centered': centered && height <= 200
      });
      return /*#__PURE__*/React.createElement("div", {
        className: classNames
      }, /*#__PURE__*/React.createElement("div", {
        id: "container",
        style: {
          flexBasis: flexBasis ? flexBasis : 'auto'
        }
      }, children));
    }
  }]);

  return SingleComponent;
}(Component);

SingleComponent.propTypes = {
  /**
    Width of Wrapper, use 'narrow' or leave empty
  */
  centered: PropTypes.bool,
  children: PropTypes.node,
  className: PropTypes.string
};
SingleComponent.defaultProps = {
  centered: true,
  pageWidth: 'lg'
};
export default SingleComponent;