content: function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
  
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
  
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
  
  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; }
  
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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); } }
  
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  
  function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  
  function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  
  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  
  import React, { Component } from 'react';
  import PropTypes from 'prop-types';
  import warn from '../utils/console/warn';
  var NEWTAB = '_blank';
  var MIDDLECLICK = 1;
  
  var OutboundLink =
  /*#__PURE__*/
  function (_Component) {
    _inherits(OutboundLink, _Component);
  
    function OutboundLink() {
      var _getPrototypeOf2;
  
      var _this;
  
      _classCallCheck(this, OutboundLink);
  
      for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
        args[_key] = arguments[_key];
      }
  
      _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(OutboundLink)).call.apply(_getPrototypeOf2, [this].concat(args)));
  
      _defineProperty(_assertThisInitialized(_this), "handleClick", function (event) {
        var _this$props = _this.props,
            target = _this$props.target,
            eventLabel = _this$props.eventLabel,
            to = _this$props.to,
            onClick = _this$props.onClick,
            trackerNames = _this$props.trackerNames;
        var eventMeta = {
          label: eventLabel
        };
        var sameTarget = target !== NEWTAB;
        var normalClick = !(event.ctrlKey || event.shiftKey || event.metaKey || event.button === MIDDLECLICK);
  
        if (sameTarget && normalClick) {
          event.preventDefault();
          OutboundLink.trackLink(eventMeta, function () {
            window.location.href = to;
          }, trackerNames);
        } else {
          OutboundLink.trackLink(eventMeta, function () {}, trackerNames);
        }
  
        if (onClick) {
          onClick(event);
        }
      });
  
      return _this;
    }
  
    _createClass(OutboundLink, [{
      key: "render",
      value: function render() {
        var _this$props2 = this.props,
            href = _this$props2.to,
            oldProps = _objectWithoutProperties(_this$props2, ["to"]);
  
        var props = _objectSpread({}, oldProps, {
          href: href,
          onClick: this.handleClick
        });
  
        if (this.props.target === NEWTAB) {
          props.rel = 'noopener noreferrer';
        }
  
        delete props.eventLabel;
        delete props.trackerNames;
        return React.createElement('a', props);
      }
    }]);
  
    return OutboundLink;
  }(Component);
  
  _defineProperty(OutboundLink, "trackLink", function () {
    warn('ga tracking not enabled');
  });
  
  _defineProperty(OutboundLink, "propTypes", {
    eventLabel: PropTypes.string.isRequired,
    target: PropTypes.string,
    to: PropTypes.string,
    onClick: PropTypes.func,
    trackerNames: PropTypes.arrayOf(PropTypes.string)
  });
  
  _defineProperty(OutboundLink, "defaultProps", {
    target: null,
    to: null,
    onClick: null,
    trackerNames: null
  });
  
  export { OutboundLink as default };