import { extractSmartLinkProvider } from '@atlaskit/link-extractors';
import { IconType } from '../../constants';
import { CONFLUENCE_GENERATOR_ID, JIRA_GENERATOR_ID } from '../constants';
var extractProvider = function extractProvider(response) {
  var provider = extractSmartLinkProvider(response);
  if (!provider) {
    return;
  }
  var providerName = provider.text;
  if (provider.id === CONFLUENCE_GENERATOR_ID) {
    return {
      icon: IconType.Confluence,
      label: providerName || 'Confluence'
    };
  }
  if (provider.id === JIRA_GENERATOR_ID) {
    return {
      icon: IconType.Jira,
      label: providerName || 'Jira'
    };
  }
  if (providerName) {
    return {
      label: providerName,
      url: typeof provider.icon === 'string' ? provider.icon : undefined
    };
  }
};
export default extractProvider;