"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

exports.__esModule = true;
exports["default"] = void 0;

var _react = _interopRequireWildcard(require("react"));

var _classnames = _interopRequireDefault(require("classnames"));

var _context = _interopRequireDefault(require("../../../context"));

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

var COLOR_MAP = {
  '1,BLUE': {
    backgroundColor: '#0072cf',
    color: '#fff',
    type: '蓝牌车'
  },
  '2,YELLOW': {
    backgroundColor: '#ffed27',
    color: '#333',
    type: '黄牌车'
  },
  '3,WHITE': {
    backgroundColor: '#fff',
    color: '#333',
    type: '白牌车'
  },
  '4,BLACK': {
    backgroundColor: '#333',
    color: '#fff',
    type: '黑牌车'
  },
  '5,GREEN': {
    backgroundColor: '#0AAF66',
    color: '#333',
    type: '绿牌车'
  }
};

var getConfig = function getConfig(plateColor) {
  var target = Object.keys(COLOR_MAP).find(function (key) {
    return key.split(',').includes("" + plateColor);
  }); // @ts-ignore

  return COLOR_MAP[target] || {};
};

var CarPlate = function CarPlate(props) {
  var _useContext = (0, _react.useContext)(_context["default"]),
      _cssPrefix = _useContext._cssPrefix;

  var className = props.className,
      plateNo = props.plateNo,
      plateColor = props.plateColor;
  var backgroundColor = getConfig(plateColor).backgroundColor || 'transparent';
  var color = getConfig(plateColor).color || '#fff';
  var border = backgroundColor === 'transparent' ? 'none' : "1px solid " + color;
  return /*#__PURE__*/_react["default"].createElement("div", {
    className: (0, _classnames["default"])(className, _cssPrefix + "car-plate-container"),
    style: {
      backgroundColor: backgroundColor
    }
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "inner",
    style: {
      border: border,
      color: color
    }
  }, plateNo || '-'));
};

var _default = /*#__PURE__*/_react["default"].memo(CarPlate);

exports["default"] = _default;