"use strict";

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

var _styledBase = require("@emotion/styled-base");

var _styledBase2 = _interopRequireDefault(_styledBase);

var _react = require("react");

var _react2 = _interopRequireDefault(_react);

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

var _propTypes2 = _interopRequireDefault(_propTypes);

var _gatsby = require("gatsby");

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

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

var SkeletonStyledComponent = exports.SkeletonStyledComponent = (
/*#__PURE__*/
0, _styledBase2["default"])(_gatsby.Link, {
  target: "eh7fx5n0",
  label: "SkeletonStyledComponent"
})(process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9jb21wb25lbnRzL0xpbmsvTGluay5Ta2VsZXRvbi5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFLbUQiLCJmaWxlIjoiLi4vLi4vLi4vc3JjL2NvbXBvbmVudHMvTGluay9MaW5rLlNrZWxldG9uLmpzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IFJlYWN0IGZyb20gXCJyZWFjdFwiXG5pbXBvcnQgUHJvcFR5cGVzIGZyb20gXCJwcm9wLXR5cGVzXCJcbmltcG9ydCBzdHlsZWQgZnJvbSBcIkBlbW90aW9uL3N0eWxlZFwiXG5pbXBvcnQgeyBMaW5rIH0gZnJvbSBcImdhdHNieVwiXG5cbmV4cG9ydCBjb25zdCBTa2VsZXRvblN0eWxlZENvbXBvbmVudCA9IHN0eWxlZChMaW5rKWBgXG5cbmV4cG9ydCBjb25zdCBsaW5rUHJvcFR5cGVzID0ge1xuICBocmVmOiBQcm9wVHlwZXMuc3RyaW5nLFxuICB0bzogUHJvcFR5cGVzLnN0cmluZyxcbiAgdGFyZ2V0OiBQcm9wVHlwZXMuc3RyaW5nLFxufVxuXG5jb25zdCBsaW5rU2tlbGV0b25Qcm9wVHlwZXMgPSB7XG4gIC4uLmxpbmtQcm9wVHlwZXMsXG4gIFN0eWxlZENvbXBvbmVudDogUHJvcFR5cGVzLmFueSxcbn1cblxuY29uc3QgbGlua1NrZWxldG9uRGVmYXVsdFByb3BUeXBlcyA9IHtcbiAgU3R5bGVkQ29tcG9uZW50OiBTa2VsZXRvblN0eWxlZENvbXBvbmVudCxcbn1cblxuY29uc3QgTGlua1NrZWxldG9uID0gKHtcbiAgU3R5bGVkQ29tcG9uZW50LFxuICBjaGlsZHJlbixcbiAgaHJlZixcbiAgdGFyZ2V0LFxuICB0byxcbiAgLi4ucmVzdFxufSkgPT4ge1xuICBpZiAoaHJlZikge1xuICAgIGNvbnN0IENvbXBvbmVudEFzRXh0ZXJuYWxMaW5rID0gU3R5bGVkQ29tcG9uZW50LndpdGhDb21wb25lbnQoYGFgKVxuICAgIHJldHVybiAoXG4gICAgICA8Q29tcG9uZW50QXNFeHRlcm5hbExpbmsgaHJlZj17aHJlZn0gdGFyZ2V0PXt0YXJnZXR9PlxuICAgICAgICB7Y2hpbGRyZW59XG4gICAgICA8L0NvbXBvbmVudEFzRXh0ZXJuYWxMaW5rPlxuICAgIClcbiAgfVxuXG4gIGlmICh0bykge1xuICAgIHJldHVybiAoXG4gICAgICA8U3R5bGVkQ29tcG9uZW50IHRvPXt0b30gey4uLnJlc3R9PlxuICAgICAgICB7Y2hpbGRyZW59XG4gICAgICA8L1N0eWxlZENvbXBvbmVudD5cbiAgICApXG4gIH1cblxuICByZXR1cm4gbnVsbFxufVxuXG5MaW5rU2tlbGV0b24ucHJvcFR5cGVzID0gbGlua1NrZWxldG9uUHJvcFR5cGVzXG5MaW5rU2tlbGV0b24uZGVmYXVsdFByb3BzID0gbGlua1NrZWxldG9uRGVmYXVsdFByb3BUeXBlc1xuXG5leHBvcnQgZGVmYXVsdCBMaW5rU2tlbGV0b25cbiJdfQ== */");
var linkPropTypes = exports.linkPropTypes = {
  href: _propTypes2["default"].string,
  to: _propTypes2["default"].string,
  target: _propTypes2["default"].string
};

var linkSkeletonPropTypes = _objectSpread({}, linkPropTypes, {
  StyledComponent: _propTypes2["default"].any
});

var linkSkeletonDefaultPropTypes = {
  StyledComponent: SkeletonStyledComponent
};

var LinkSkeleton = function LinkSkeleton(_ref) {
  var StyledComponent = _ref.StyledComponent,
      children = _ref.children,
      href = _ref.href,
      target = _ref.target,
      to = _ref.to,
      rest = _objectWithoutProperties(_ref, ["StyledComponent", "children", "href", "target", "to"]);

  if (href) {
    var ComponentAsExternalLink = StyledComponent.withComponent("a", {
      target: "eh7fx5n1",
      label: "ComponentAsExternalLink"
    });
    return _react2["default"].createElement(ComponentAsExternalLink, {
      href: href,
      target: target
    }, children);
  }

  if (to) {
    return _react2["default"].createElement(StyledComponent, Object.assign({
      to: to
    }, rest), children);
  }

  return null;
};

LinkSkeleton.propTypes = linkSkeletonPropTypes;
LinkSkeleton.defaultProps = linkSkeletonDefaultPropTypes;
exports["default"] = LinkSkeleton;