import React from 'react';
import { injectIntl } from 'react-intl';
import Rusha from 'rusha';
import BlogObject from '@atlaskit/object/blog';
import BugObject from '@atlaskit/object/bug';
import PageObject from '@atlaskit/object/page';
import StoryObject from '@atlaskit/object/story';
import TaskObject from '@atlaskit/object/task';
import WorkItemObject from '@atlaskit/object/work-item';
import { fg } from '@atlaskit/platform-feature-flags';
import { utilMessages } from './messages';
export function filterUniqueItems(arr, comparator) {
  return arr.filter(function (firstItem, index, self) {
    return self.findIndex(function (secondItem) {
      return comparator ? comparator(firstItem, secondItem) : firstItem === secondItem;
    }) === index;
  });
}
var Issue16 = function Issue16(props) {
  var intl = props.intl;
  return /*#__PURE__*/React.createElement(WorkItemObject, {
    label: intl.formatMessage(fg('confluence-issue-terminology-refresh') ? utilMessages.hyperlinkIconIssueLabelIssueTermRefresh : utilMessages.hyperlinkIconIssueLabel)
  });
};
var Bug16 = function Bug16(props) {
  var intl = props.intl;
  return /*#__PURE__*/React.createElement(BugObject, {
    label: intl.formatMessage(utilMessages.hyperlinkIconBugLabel)
  });
};
var Story16 = function Story16(props) {
  var intl = props.intl;
  return /*#__PURE__*/React.createElement(StoryObject, {
    label: intl.formatMessage(utilMessages.hyperlinkIconStoryLabel)
  });
};
var Task16 = function Task16(props) {
  var intl = props.intl;
  return /*#__PURE__*/React.createElement(TaskObject, {
    label: intl.formatMessage(utilMessages.hyperlinkIconTaskLabel)
  });
};
var Page16 = function Page16(props) {
  var intl = props.intl;
  return /*#__PURE__*/React.createElement(PageObject, {
    label: intl.formatMessage(utilMessages.hyperlinkIconPageLabel)
  });
};
var Blog16 = function Blog16(props) {
  var intl = props.intl;
  return /*#__PURE__*/React.createElement(BlogObject, {
    label: intl.formatMessage(utilMessages.hyperlinkIconBlogLabel)
  });
};
var IntlIssue16Icon = injectIntl(Issue16);
var IntlBug16Icon = injectIntl(Bug16);
var IntlStory16Icon = injectIntl(Story16);
var IntlTask16Icon = injectIntl(Task16);
var IntlPage16Icon = injectIntl(Page16);
var IntlBlog16Icon = injectIntl(Blog16);
export var mapContentTypeToIcon = {
  'jira.issue': /*#__PURE__*/React.createElement(IntlIssue16Icon, null),
  'jira.issue.bug': /*#__PURE__*/React.createElement(IntlBug16Icon, null),
  'jira.issue.story': /*#__PURE__*/React.createElement(IntlStory16Icon, null),
  'jira.issue.task': /*#__PURE__*/React.createElement(IntlTask16Icon, null),
  'confluence.page': /*#__PURE__*/React.createElement(IntlPage16Icon, null),
  'confluence.blogpost': /*#__PURE__*/React.createElement(IntlBlog16Icon, null)
};
export var sha1 = function sha1(input) {
  return Rusha.createHash().update(input).digest('hex');
};
export var wordCount = function wordCount(input) {
  return input.split(' ').length;
};