"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.titleBlockOptions = exports.getSimulatedBetterMetadata = exports.PreviewBlockOptions = exports.FlexibleCardUiOptions = void 0;
var _constants = require("../../../../constants");
var _utils = require("../../../../extractors/flexible/utils");
var _helpers = require("../../../../state/helpers");
var baseTopMetadata = [{
  name: _constants.ElementName.ModifiedOn
}, {
  name: _constants.ElementName.AttachmentCount
}, {
  name: _constants.ElementName.SubscriberCount
}, {
  name: _constants.ElementName.VoteCount
}, {
  name: _constants.ElementName.DueOn
}, {
  name: _constants.ElementName.ReadTime
}];
var baseBottomMetaData = [{
  name: _constants.ElementName.ReactCount
}, {
  name: _constants.ElementName.CommentCount
}, {
  name: _constants.ElementName.ViewCount
}, {
  name: _constants.ElementName.Priority
}, {
  name: _constants.ElementName.SubTasksProgress
}, {
  name: _constants.ElementName.ChecklistProgress
}];
var getSimulatedBetterMetadata = exports.getSimulatedBetterMetadata = function getSimulatedBetterMetadata(cardDetails) {
  var _getExtensionKey, _data$Type$includes, _data$Type;
  var extensionKey = (_getExtensionKey = (0, _helpers.getExtensionKey)(cardDetails)) !== null && _getExtensionKey !== void 0 ? _getExtensionKey : '';
  var data = cardDetails === null || cardDetails === void 0 ? void 0 : cardDetails.data;
  var defaultTitleMetadata = [{
    name: _constants.ElementName.State
  }];
  var defaultTopMetadata = [{
    name: _constants.ElementName.AuthorGroup
  }, {
    name: _constants.ElementName.CreatedBy
  }].concat(baseTopMetadata);
  var defaultBottomMetadata = baseBottomMetaData;
  switch (extensionKey) {
    case 'bitbucket-object-provider':
    case 'native-bitbucket-object-provider':
      var isFile = data['@type'].includes('schema:DigitalDocument');
      return {
        titleMetadata: defaultTitleMetadata,
        topMetadata: isFile ? [{
          name: _constants.ElementName.LatestCommit
        }, {
          name: _constants.ElementName.CollaboratorGroup
        }, {
          name: _constants.ElementName.ModifiedOn
        }] : defaultTopMetadata,
        bottomMetadata: defaultBottomMetadata
      };
    case 'dragonfruit-object-provider':
      return {
        titleMetadata: defaultTitleMetadata,
        topMetadata: (0, _utils.extractOwnedBy)(data) ? [{
          name: _constants.ElementName.OwnedByGroup
        }, {
          name: _constants.ElementName.OwnedBy
        }].concat(baseTopMetadata) : defaultTopMetadata,
        bottomMetadata: [{
          name: _constants.ElementName.AppliedToComponentsCount
        }].concat(baseBottomMetaData)
      };
    case 'integration-passionfruit-object-provider':
      return {
        titleMetadata: defaultTitleMetadata,
        topMetadata: (0, _utils.extractOwnedBy)(data) ? [{
          name: _constants.ElementName.OwnedByGroup
        }, {
          name: _constants.ElementName.OwnedBy
        }].concat(baseTopMetadata) : defaultTopMetadata,
        bottomMetadata: [{
          name: _constants.ElementName.AppliedToComponentsCount
        }].concat(baseBottomMetaData)
      };
    case 'confluence-object-provider':
      return {
        titleMetadata: defaultTitleMetadata,
        topMetadata: (0, _utils.extractOwnedBy)(data) ? [{
          name: _constants.ElementName.OwnedByGroup
        }, {
          name: _constants.ElementName.OwnedBy
        }].concat(baseTopMetadata) : defaultTopMetadata,
        bottomMetadata: defaultBottomMetadata
      };
    case 'jira-object-provider':
      var isJiraTask = (_data$Type$includes = (_data$Type = data['@type']) === null || _data$Type === void 0 ? void 0 : _data$Type.includes('atlassian:Task')) !== null && _data$Type$includes !== void 0 ? _data$Type$includes : false;
      var isJiraPlan = data['atlassian:ownedBy'] ? true : false;
      var topMetadata = [{
        name: _constants.ElementName.AuthorGroup
      }, {
        name: _constants.ElementName.CreatedBy
      }, {
        name: _constants.ElementName.ModifiedOn
      }];
      if (isJiraTask) {
        topMetadata = [{
          name: _constants.ElementName.AssignedToGroup
        }, {
          name: _constants.ElementName.AssignedTo
        }, {
          name: _constants.ElementName.ModifiedOn
        }];
      } else if (isJiraPlan) {
        topMetadata = [{
          name: _constants.ElementName.OwnedByGroup
        }, {
          name: _constants.ElementName.OwnedBy
        }];
      }
      return {
        titleMetadata: defaultTitleMetadata,
        topMetadata: topMetadata,
        bottomMetadata: [{
          name: _constants.ElementName.StoryPoints
        }, {
          name: _constants.ElementName.Priority
        }, {
          name: _constants.ElementName.SubTasksProgress
        }]
      };
    case 'slack-object-provider':
      return {
        titleMetadata: defaultTitleMetadata,
        topMetadata: [{
          name: _constants.ElementName.AuthorGroup
        }, {
          name: _constants.ElementName.SentOn
        }],
        bottomMetadata: [{
          name: _constants.ElementName.ReactCount
        }, {
          name: _constants.ElementName.CommentCount
        }]
      };
    case 'trello-object-provider':
      return {
        titleMetadata: defaultTitleMetadata,
        topMetadata: [{
          name: _constants.ElementName.CollaboratorGroup
        }].concat(baseTopMetadata),
        bottomMetadata: defaultBottomMetadata
      };
    case 'legion-object-provider':
    case 'people-object-provider':
      return {
        titleMetadata: defaultTitleMetadata,
        topMetadata: [{
          name: _constants.ElementName.AuthorGroup
        }, {
          name: _constants.ElementName.TeamMemberCount
        }, {
          name: _constants.ElementName.UserAttributes
        }].concat(baseTopMetadata),
        bottomMetadata: defaultBottomMetadata
      };
    default:
      return {
        titleMetadata: defaultTitleMetadata,
        topMetadata: defaultTopMetadata,
        bottomMetadata: defaultBottomMetadata
      };
  }
};
var FlexibleCardUiOptions = exports.FlexibleCardUiOptions = {
  hideElevation: true,
  hideLegacyButton: true,
  removeBlockRestriction: true
};
var titleBlockOptions = exports.titleBlockOptions = {
  anchorTarget: '_self',
  position: _constants.SmartLinkPosition.Center,
  hideRetry: true,
  size: _constants.SmartLinkSize.Large
};
var PreviewBlockOptions = exports.PreviewBlockOptions = {
  placement: _constants.MediaPlacement.Right,
  ignoreContainerPadding: true
};