"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.extractSummary = exports.extractSmartLinkSummary = void 0;
var _linkExtractors = require("@atlaskit/link-extractors");
/**
 * Return link summary
 */
var extractSummary = exports.extractSummary = function extractSummary(jsonLd) {
  if (typeof (jsonLd === null || jsonLd === void 0 ? void 0 : jsonLd.summary) === 'string') {
    var summary = jsonLd.summary.trim();
    return Boolean(summary) ? summary : undefined;
  }
};

/**
 * Return link summary
 */
var extractSmartLinkSummary = exports.extractSmartLinkSummary = function extractSmartLinkSummary(response) {
  if ((0, _linkExtractors.isEntityPresent)(response)) {
    var _extractEntity;
    return (_extractEntity = (0, _linkExtractors.extractEntity)(response)) === null || _extractEntity === void 0 ? void 0 : _extractEntity.description;
  }
  return (response === null || response === void 0 ? void 0 : response.data) && extractSummary(response.data);
};