import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
import _createClass from "@babel/runtime/helpers/createClass";
import _inherits from "@babel/runtime/helpers/inherits";
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
/** @jsx jsx */
import { PureComponent } from 'react';
import { css, jsx } from '@emotion/react';
import Spinner from '@atlaskit/spinner';
import { N30 } from '@atlaskit/theme/colors';
import LinkSearchListItem from './LinkSearchListItem';
var listContainer = css({
  paddingTop: 0,
  marginTop: "var(--ds-space-150, 12px)",
  borderTop: "1px solid ".concat("var(--ds-border, ".concat(N30, ")"))
});
var spinnerContainer = css({
  textAlign: 'center',
  minHeight: '80px',
  marginTop: "var(--ds-space-400, 32px)"
});
export var linkSearchList = css({
  padding: 0,
  listStyle: 'none'
});
var LinkSearchList = /*#__PURE__*/function (_PureComponent) {
  _inherits(LinkSearchList, _PureComponent);
  var _super = _createSuper(LinkSearchList);
  function LinkSearchList() {
    _classCallCheck(this, LinkSearchList);
    return _super.apply(this, arguments);
  }
  _createClass(LinkSearchList, [{
    key: "render",
    value: function render() {
      var _this$props = this.props,
        onSelect = _this$props.onSelect,
        onMouseMove = _this$props.onMouseMove,
        onMouseEnter = _this$props.onMouseEnter,
        onMouseLeave = _this$props.onMouseLeave,
        items = _this$props.items,
        selectedIndex = _this$props.selectedIndex,
        isLoading = _this$props.isLoading,
        ariaControls = _this$props.ariaControls,
        role = _this$props.role,
        id = _this$props.id;
      var itemsContent;
      var loadingContent;
      if (items && items.length > 0) {
        itemsContent = jsx("ul", {
          css: linkSearchList,
          id: id,
          role: role,
          "aria-controls": ariaControls
        }, items.map(function (item, index) {
          return jsx(LinkSearchListItem, {
            id: "link-search-list-item-".concat(index),
            role: role && 'option',
            item: item,
            selected: selectedIndex === index,
            onMouseMove: onMouseMove,
            onMouseEnter: onMouseEnter,
            onMouseLeave: onMouseLeave,
            onSelect: onSelect,
            key: item.objectId
          });
        }));
      }
      if (isLoading) {
        loadingContent = jsx("div", {
          "data-testid": "".concat(id, "-loading"),
          css: spinnerContainer
        }, jsx(Spinner, {
          size: "medium"
        }));
      }
      return jsx("div", {
        css: listContainer
      }, itemsContent, loadingContent);
    }
  }]);
  return LinkSearchList;
}(PureComponent);
export { LinkSearchList as default };