"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _linkExtractors = require("@atlaskit/link-extractors");
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
var _constants = require("../../../constants");
/**
 * Computes the relevant icon for a document type.
 *
 * @remark Note that document icons can vary based on the provider. E.g., a
 * provider may choose to re-use one of these document types in their domain,
 * but offer a different SVG icon on the frontend (to map to this type in their
 * domain). See `schema:digitalDocument` for an example of this behaviour. This
 * mechanism will be superseded by backend-driven icon URLs as part of
 * go/j/MODES-5864. Do not add more!
 *
 * @param documentType JSON-LD document type
 * @param label human-readable label to be displayed on the icon
 * @param providerId JSON-LD provider (generator ID)
 * @returns an icon descriptor representing the document type
 */
var extractDocumentTypeIcon = function extractDocumentTypeIcon(documentType, label, providerId) {
  switch (documentType) {
    case 'schema:BlogPosting':
      return (0, _platformFeatureFlags.fg)('navx-2827-eslint-object-translation-smart-links') ? {
        icon: _constants.IconType.Blog,
        label: label
      } : {
        icon: _constants.IconType.Blog,
        // eslint-disable-next-line @atlassian/i18n/no-literal-string-in-object
        label: label || 'Blog'
      };
    case 'schema:DigitalDocument':
      if (providerId && (0, _linkExtractors.isConfluenceGenerator)(providerId)) {
        return (0, _platformFeatureFlags.fg)('navx-2827-eslint-object-translation-smart-links') ? {
          icon: _constants.IconType.LiveDocument,
          label: label
        } : {
          icon: _constants.IconType.LiveDocument,
          // eslint-disable-next-line @atlassian/i18n/no-literal-string-in-object
          label: label || 'Live Document'
        };
      } else {
        return (0, _platformFeatureFlags.fg)('navx-2827-eslint-object-translation-smart-links') ? {
          icon: _constants.IconType.File,
          label: label
        } : {
          icon: _constants.IconType.File,
          // eslint-disable-next-line @atlassian/i18n/no-literal-string-in-object
          label: label || 'File'
        };
      }
    case 'schema:TextDigitalDocument':
      return (0, _platformFeatureFlags.fg)('navx-2827-eslint-object-translation-smart-links') ? {
        icon: _constants.IconType.Document,
        label: label
      } : {
        icon: _constants.IconType.Document,
        // eslint-disable-next-line @atlassian/i18n/no-literal-string-in-object
        label: label || 'Document'
      };
    case 'schema:PresentationDigitalDocument':
      return (0, _platformFeatureFlags.fg)('navx-2827-eslint-object-translation-smart-links') ? {
        icon: _constants.IconType.Presentation,
        label: label
      } : {
        icon: _constants.IconType.Presentation,
        // eslint-disable-next-line @atlassian/i18n/no-literal-string-in-object
        label: label || 'Presentation'
      };
    case 'schema:SpreadsheetDigitalDocument':
      return (0, _platformFeatureFlags.fg)('navx-2827-eslint-object-translation-smart-links') ? {
        icon: _constants.IconType.Spreadsheet,
        label: label
      } : {
        icon: _constants.IconType.Spreadsheet,
        // eslint-disable-next-line @atlassian/i18n/no-literal-string-in-object
        label: label || 'Spreadsheet'
      };
    case 'atlassian:Template':
      return (0, _platformFeatureFlags.fg)('navx-2827-eslint-object-translation-smart-links') ? {
        icon: _constants.IconType.Template,
        label: label
      } : {
        icon: _constants.IconType.Template,
        // eslint-disable-next-line @atlassian/i18n/no-literal-string-in-object
        label: label || 'Template'
      };
    case 'atlassian:UndefinedLink':
      return (0, _platformFeatureFlags.fg)('navx-2827-eslint-object-translation-smart-links') ? {
        icon: _constants.IconType.Document,
        label: label
      } : {
        icon: _constants.IconType.Document,
        // eslint-disable-next-line @atlassian/i18n/no-literal-string-in-object
        label: label || 'Undefined link'
      };
    default:
      return undefined;
  }
};
var _default = exports.default = extractDocumentTypeIcon;