import React__default from 'react';
import PropTypes from 'prop-types';
import { settings } from '../../constants/Settings.js';
import CardIcon from '../ImageCard/CardIcon.js';

var iotPrefix = settings.iotPrefix;
var propTypes = {
  /** severities will determine which default icon to use if another icon name isn't provided */
  severity: PropTypes.oneOf([1, 2, 3]),
  /** the title to show when hovering over the icon */
  title: PropTypes.string,
  /** the name of the icon to load or a react element to render */
  icon: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
  /** the css color to set the icon */
  color: PropTypes.string,
  /** set of internationalized strings */
  strings: PropTypes.shape({
    criticalLabel: PropTypes.string,
    moderateLabel: PropTypes.string,
    lowLabel: PropTypes.string
  }).isRequired,
  /** Optionally shows threshold severity label text. Shows by default */
  showSeverityLabel: PropTypes.bool,
  /** Optionally changes threshold severity label text */
  severityLabel: PropTypes.string,
  /** optional function that returns an icon node for an icon name */
  renderIconByName: PropTypes.func
};
var defaultProps = {
  severity: null,
  title: null,
  icon: null,
  color: null,
  showSeverityLabel: true,
  severityLabel: null,
  renderIconByName: null
};
var ThresholdIcon = function ThresholdIcon(_ref) {
  var severity = _ref.severity,
    strings = _ref.strings,
    title = _ref.title,
    icon = _ref.icon,
    color = _ref.color,
    showSeverityLabel = _ref.showSeverityLabel,
    severityLabel = _ref.severityLabel,
    renderIconByName = _ref.renderIconByName;
  var iconToRender;
  var stringToRender = '';
  var customIcon = icon ? /*#__PURE__*/React__default.createElement(CardIcon, {
    icon: icon,
    title: title,
    color: color || '#DA1E28',
    renderIconByName: renderIconByName,
    width: 16,
    height: 16
  }) : null;
  switch (severity) {
    case 1:
      iconToRender = customIcon || /*#__PURE__*/React__default.createElement(CardIcon, {
        icon: "Misuse",
        title: title,
        color: color || '#DA1E28',
        renderIconByName: renderIconByName,
        width: 16,
        height: 16
      });
      stringToRender = strings.criticalLabel;
      break;
    case 2:
      iconToRender = customIcon || /*#__PURE__*/React__default.createElement(CardIcon, {
        icon: "Warning alt filled",
        title: title,
        color: color || '#FC7B1E',
        renderIconByName: renderIconByName,
        width: 16,
        height: 16
      });
      stringToRender = strings.moderateLabel;
      break;
    case 3:
      iconToRender = customIcon || /*#__PURE__*/React__default.createElement(CardIcon, {
        icon: "Information filled",
        title: title,
        color: color || '#FDD13A',
        renderIconByName: renderIconByName,
        width: 16,
        height: 16
      });
      stringToRender = strings.lowLabel;
      break;
  }
  return /*#__PURE__*/React__default.createElement("div", {
    className: "".concat(iotPrefix, "--threshold-icon--wrapper"),
    title: title
  }, iconToRender, showSeverityLabel ? /*#__PURE__*/React__default.createElement("span", {
    className: "".concat(iotPrefix, "--threshold-icon--text")
  }, severityLabel || stringToRender) : null);
};
ThresholdIcon.propTypes = propTypes;
ThresholdIcon.defaultProps = defaultProps;
ThresholdIcon.__docgenInfo = {
  "description": "",
  "methods": [],
  "displayName": "ThresholdIcon",
  "props": {
    "severity": {
      "defaultValue": {
        "value": "null",
        "computed": false
      },
      "description": "severities will determine which default icon to use if another icon name isn't provided",
      "type": {
        "name": "enum",
        "value": [{
          "value": "1",
          "computed": false
        }, {
          "value": "2",
          "computed": false
        }, {
          "value": "3",
          "computed": false
        }]
      },
      "required": false
    },
    "title": {
      "defaultValue": {
        "value": "null",
        "computed": false
      },
      "description": "the title to show when hovering over the icon",
      "type": {
        "name": "string"
      },
      "required": false
    },
    "icon": {
      "defaultValue": {
        "value": "null",
        "computed": false
      },
      "description": "the name of the icon to load or a react element to render",
      "type": {
        "name": "union",
        "value": [{
          "name": "string"
        }, {
          "name": "element"
        }]
      },
      "required": false
    },
    "color": {
      "defaultValue": {
        "value": "null",
        "computed": false
      },
      "description": "the css color to set the icon",
      "type": {
        "name": "string"
      },
      "required": false
    },
    "showSeverityLabel": {
      "defaultValue": {
        "value": "true",
        "computed": false
      },
      "description": "Optionally shows threshold severity label text. Shows by default",
      "type": {
        "name": "bool"
      },
      "required": false
    },
    "severityLabel": {
      "defaultValue": {
        "value": "null",
        "computed": false
      },
      "description": "Optionally changes threshold severity label text",
      "type": {
        "name": "string"
      },
      "required": false
    },
    "renderIconByName": {
      "defaultValue": {
        "value": "null",
        "computed": false
      },
      "description": "optional function that returns an icon node for an icon name",
      "type": {
        "name": "func"
      },
      "required": false
    },
    "strings": {
      "description": "set of internationalized strings",
      "type": {
        "name": "shape",
        "value": {
          "criticalLabel": {
            "name": "string",
            "required": false
          },
          "moderateLabel": {
            "name": "string",
            "required": false
          },
          "lowLabel": {
            "name": "string",
            "required": false
          }
        }
      },
      "required": true
    }
  }
};
var ThresholdIcon$1 = ThresholdIcon;

export { ThresholdIcon$1 as default };
