import "choerodon-ui/lib/tooltip/style";
import _Tooltip from "choerodon-ui/lib/tooltip";

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

import React, { useMemo } from 'react';
import "./index.less";
export default function StatusTag(_ref) {
  var name = _ref.name,
      color = _ref.color,
      colorCode = _ref.colorCode,
      style = _ref.style,
      ellipsis = _ref.ellipsis,
      error = _ref.error;
  var colorMappings = useMemo(function () {
    return {
      success: '#00bf96',
      running: '#00bf96',
      error: '#f44336',
      failed: '#f44336',
      merged: '#4d90fe',
      operating: '#4d90fe',
      opened: '#ffb100',
      ready: '#57aaf8',
      unready: 'rgba(0,0,0,0.20)',
      deleted: 'rgba(0,0,0,0.36)',
      finished: '#00bf96',
      pendingcheck: '#ffb100',
      active: '#00bf96',
      creating: '#4d90fe',
      disconnect: '#ff9915',
      executing: '#4d90fe',
      stop: '#ff7043',
      bound: 'rgba(0, 191, 165, 1)',
      pending: 'rgba(255, 177, 0, 1)',
      lost: 'rgba(0, 0, 0, 0.26)',
      terminating: ''
    };
  }, []);
  var defaultColor = 'rgba(0, 0, 0, 0.28)';
  var tagNode = /*#__PURE__*/React.createElement(_Tooltip, {
    title: ellipsis ? name : error
  }, name || '');
  return /*#__PURE__*/React.createElement("div", {
    className: "c7ncd-status-tag",
    style: _objectSpread({
      background: color || colorMappings[colorCode.toLocaleLowerCase()] || defaultColor
    }, style)
  }, ellipsis ? /*#__PURE__*/React.createElement("div", {
    className: "c7ncd-status-tag-wrap"
  }, tagNode) : tagNode);
}