/* eslint-disable @atlaskit/ui-styling-standard/use-compiled -- Pre-existing lint debt surfaced by this mechanical type-import-only PR. */
/**
 * @jsxRuntime classic
 * @jsx jsx
 */

// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled, @typescript-eslint/consistent-type-imports -- Ignored via go/DSP-18766; jsx required at runtime for @jsxRuntime classic
import { css, jsx } from '@emotion/react';
import Spinner from '@atlaskit/spinner';
import ForwardedLinkSearchListItemNextWithIntl from './LinkSearchListItem';
const listContainer = css({
  paddingTop: 0,
  marginTop: "var(--ds-space-150, 12px)",
  borderTop: `${"var(--ds-border-width, 1px)"} solid ${"var(--ds-border, #0B120E24)"}`
});
const spinnerContainer = css({
  textAlign: 'center',
  minHeight: '80px',
  marginTop: "var(--ds-space-400, 32px)"
});

// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles -- Ignored via go/DSP-18766
export const linkSearchList = css({
  padding: 0,
  listStyle: 'none'
});
const LinkSearchList = ({
  listItemRefCallback,
  onBlur,
  onFocus,
  onKeyDown,
  onSelect,
  onMouseMove,
  onMouseEnter,
  onMouseLeave,
  items,
  selectedIndex,
  isLoading,
  ariaControls,
  role,
  id
}) => {
  let itemsContent;
  let loadingContent;
  if (items && items.length > 0) {
    itemsContent = jsx("ul", {
      css: linkSearchList,
      id: id,
      role: role,
      "aria-controls": ariaControls,
      "data-testid": `${id}--items`
    }, items.map((item, index) => jsx(ForwardedLinkSearchListItemNextWithIntl, {
      id: `link-search-list-item-${index}`,
      item: item,
      selected: selectedIndex === index,
      onBlur: onBlur
      // eslint-disable-next-line @atlassian/perf-linting/detect-unnecessary-rerenders, @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
      ,
      onFocus: () => onFocus === null || onFocus === void 0 ? void 0 : onFocus(index),
      onKeyDown: onKeyDown,
      onMouseMove: onMouseMove,
      onMouseEnter: onMouseEnter,
      onMouseLeave: onMouseLeave,
      onSelect: onSelect,
      key: item.objectId
      // eslint-disable-next-line @atlassian/perf-linting/detect-unnecessary-rerenders, @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
      ,
      ref: el => listItemRefCallback === null || listItemRefCallback === void 0 ? void 0 : listItemRefCallback(el, item.objectId)
    })));
  }
  if (isLoading) {
    loadingContent = jsx("div", {
      id: id,
      "data-testid": `${id}--loading`,
      css: spinnerContainer
    }, jsx(Spinner, {
      size: "medium",
      interactionName: "link-search-spinner"
    }));
  }
  return jsx("div", {
    css: listContainer
  }, itemsContent, loadingContent);
};

// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
export default LinkSearchList;