"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _linkExtractors = require("@atlaskit/link-extractors");
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':
      // eslint-disable-next-line @atlassian/i18n/no-literal-string-in-object
      return {
        icon: _constants.IconType.Blog,
        label: label || 'Blog'
      };
    case 'schema:DigitalDocument':
      if (providerId && (0, _linkExtractors.isConfluenceGenerator)(providerId)) {
        // eslint-disable-next-line @atlassian/i18n/no-literal-string-in-object
        return {
          icon: _constants.IconType.LiveDocument,
          label: label || 'Live Document'
        };
      } else {
        // eslint-disable-next-line @atlassian/i18n/no-literal-string-in-object
        return {
          icon: _constants.IconType.File,
          label: label || 'File'
        };
      }
    case 'schema:TextDigitalDocument':
      // eslint-disable-next-line @atlassian/i18n/no-literal-string-in-object
      return {
        icon: _constants.IconType.Document,
        label: label || 'Document'
      };
    case 'schema:PresentationDigitalDocument':
      // eslint-disable-next-line @atlassian/i18n/no-literal-string-in-object
      return {
        icon: _constants.IconType.Presentation,
        label: label || 'Presentation'
      };
    case 'schema:SpreadsheetDigitalDocument':
      // eslint-disable-next-line @atlassian/i18n/no-literal-string-in-object
      return {
        icon: _constants.IconType.Spreadsheet,
        label: label || 'Spreadsheet'
      };
    case 'atlassian:Template':
      // eslint-disable-next-line @atlassian/i18n/no-literal-string-in-object
      return {
        icon: _constants.IconType.Template,
        label: label || 'Template'
      };
    case 'atlassian:UndefinedLink':
      // eslint-disable-next-line @atlassian/i18n/no-literal-string-in-object
      return {
        icon: _constants.IconType.Document,
        label: label || 'Undefined link'
      };
    default:
      return undefined;
  }
};
var _default = exports.default = extractDocumentTypeIcon;