import React, { useContext } from 'react';
import { useResponsiveLayout } from "../../../../../components/ResponsiveLayout";
import { ThemeContext } from "../../../../../lib/theming/ThemeContext";
import { isThemeGTE } from "../../../../../lib/theming/ThemeHelpers";
import { FileUploaderFileStatus } from "../../../fileUtils";
import { LoadingIcon } from "../../../../icons2022/LoadingIcon";
import { jsTileStyles, jsRowStyles } from "../../FileUploaderFile.styles";
import { DeleteIcon } from "../DeleteIcon";
import { ErrorIcon } from "../ErrorIcon";

// import { ActionIcon } from './ActionIcon';

export var FileUploaderFileStatusIcon = function FileUploaderFileStatusIcon(_ref) {
  var hovered = _ref.hovered,
    isTileView = _ref.isTileView,
    disabled = _ref.disabled,
    focusedByTab = _ref.focusedByTab,
    isInvalid = _ref.isInvalid,
    status = _ref.status,
    size = _ref.size,
    hasValidation = _ref.hasValidation;
  var _useResponsiveLayout = useResponsiveLayout(),
    isMobile = _useResponsiveLayout.isMobile;
  var theme = useContext(ThemeContext);
  var versionGTE5_5 = isThemeGTE(theme, '5.5');
  var iconClassNames = isTileView ? jsTileStyles.iconColor(theme) : jsRowStyles.iconColor(theme);
  var IconDelete = /*#__PURE__*/React.createElement(DeleteIcon, {
    size: size,
    className: iconClassNames
  });
  // const IconAction = <ActionIcon size={size} className={iconClassNames} />;
  var IconError = /*#__PURE__*/React.createElement(ErrorIcon, {
    size: size
  });
  if (versionGTE5_5) {
    if (status === FileUploaderFileStatus.Loading) {
      return hovered || isTileView ? IconDelete : /*#__PURE__*/React.createElement(LoadingIcon, {
        size: size
      });
    }
    if (disabled || !isMobile && !hovered && !focusedByTab) {
      return null;
    }
    if (isInvalid || hasValidation) {
      return IconDelete;
    }
  } else {
    if (hovered || focusedByTab) {
      return IconDelete;
    }
    if (isInvalid) {
      return IconError;
    }
  }
  switch (status) {
    case FileUploaderFileStatus.Loading:
      return /*#__PURE__*/React.createElement(LoadingIcon, {
        size: size
      });
    // TODO - IF-2270 - добавить логику для действий по наведению и клику, пока только удаление
    default:
      return IconDelete;
  }
};