'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.LinkBox = undefined;

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

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _classnames = require('classnames');

var _classnames2 = _interopRequireDefault(_classnames);

var _arrowIcon = require('kitten/components/icons/arrow-icon');

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

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }

var LinkBox = exports.LinkBox = function (_Component) {
  _inherits(LinkBox, _Component);

  function LinkBox() {
    _classCallCheck(this, LinkBox);

    return _possibleConstructorReturn(this, (LinkBox.__proto__ || Object.getPrototypeOf(LinkBox)).apply(this, arguments));
  }

  _createClass(LinkBox, [{
    key: 'renderIcon',
    value: function renderIcon() {
      if (this.props.displayIcon) {
        return _react2.default.createElement(
          'div',
          { className: 'k-LinkBox__icon' },
          this.props.children
        );
      }
    }
  }, {
    key: 'render',
    value: function render() {
      var _props = this.props,
          className = _props.className,
          displayIcon = _props.displayIcon,
          isExternal = _props.isExternal,
          href = _props.href,
          title = _props.title,
          text = _props.text,
          linkProps = _props.linkProps;


      var linkBoxClassNames = (0, _classnames2.default)('k-LinkBox', className, {
        'k-LinkBox--withIcon': displayIcon
      });

      var target = isExternal ? { target: '_blank' } : {};

      return _react2.default.createElement(
        'a',
        _extends({}, linkProps, { className: linkBoxClassNames, href: href }, target),
        _react2.default.createElement(
          'div',
          { className: 'k-LinkBox__container' },
          this.renderIcon(),
          _react2.default.createElement(
            'div',
            { className: 'k-LinkBox__paragraph' },
            _react2.default.createElement(
              'p',
              { className: 'k-LinkBox__title' },
              title
            ),
            _react2.default.createElement(
              'p',
              { className: 'k-LinkBox__text' },
              text
            )
          ),
          _react2.default.createElement(
            'div',
            { className: 'k-LinkBox__navigation' },
            _react2.default.createElement(_arrowIcon.ArrowIcon, { className: 'k-ButtonIcon__svg' })
          )
        )
      );
    }
  }]);

  return LinkBox;
}(_react.Component);

LinkBox.defaultProps = {
  displayIcon: false,
  href: '#',
  isExternal: false

  // DEPRECATED: do not use default export.
};exports.default = LinkBox;