'use strict';

exports.__esModule = true;

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _propTypes = require('prop-types');

var _propTypes2 = _interopRequireDefault(_propTypes);

var _reactHtmlParser = require('react-html-parser');

var _reactHtmlParser2 = _interopRequireDefault(_reactHtmlParser);

var _DecorativeLink = require('../../links/DecorativeLink');

var _DecorativeLink2 = _interopRequireDefault(_DecorativeLink);

require('./style.css');

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

var Address = function Address(props) {
  var address = props.address,
      directionLink = props.directionLink,
      details = props.details;

  return _react2.default.createElement(
    'span',
    { className: 'ma__address' },
    address.streetAddress ? _react2.default.createElement(
      'div',
      { className: 'ma__address__address' },
      _react2.default.createElement(
        'div',
        { className: 'ma__address__part' },
        address.streetAddress
      ),
      _react2.default.createElement(
        'div',
        { className: 'ma__address__part' },
        address.muni + ', ' + address.state + ' ' + address.zip
      )
    ) : _react2.default.createElement(
      'div',
      { className: 'ma__address__address' },
      (0, _reactHtmlParser2.default)(address)
    ),
    details && _react2.default.createElement(
      'p',
      { className: 'ma__contact__details' },
      (0, _reactHtmlParser2.default)(details)
    ),
    directionLink && _react2.default.createElement(
      'div',
      { className: 'ma__address__directions' },
      _react2.default.createElement(_DecorativeLink2.default, { text: 'Directions', href: directionLink })
    )
  );
};

Address.propTypes = process.env.NODE_ENV !== "production" ? {
  /** An object or string representing the address.
      If parsed the object contains the following:
        streetAddress: street number, name, if applicable apt/unit number
        muni: municipality/city/town
        state: state
        zip: zipcode
        country: country
      If a simple string just passed as:
        address: full address. */
  address: _propTypes2.default.oneOfType([_propTypes2.default.shape({
    streetAddress: _propTypes2.default.string,
    muni: _propTypes2.default.string,
    state: _propTypes2.default.string,
    zip: _propTypes2.default.string,
    country: _propTypes2.default.string
  }), _propTypes2.default.string, _propTypes2.default.object]).isRequired,
  /** A link to the directions of the address. */
  directionLink: _propTypes2.default.string,
  /** Details around visiting the address. */
  details: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.object])
} : {};

exports.default = Address;
module.exports = exports['default'];