"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;

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

var _propTypes = _interopRequireDefault(require("prop-types"));

var _vmGasModal = _interopRequireDefault(require("../vm-gas-modal"));

var _base = _interopRequireDefault(require("./base"));

var _useModal2 = _interopRequireDefault(require("../vm-hooks/useModal"));

require("./style");

var _historyList = _interopRequireDefault(require("./historyList"));

var _excluded = ["info"],
    _excluded2 = ["showModal"];

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }

function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }

var TABS_BASE = 'gas-alarm-base';
var TABS_HISTORY = 'gas-alarm-history';

var Modal = function Modal(_ref) {
  var _ref$info = _ref.info,
      info = _ref$info === void 0 ? {} : _ref$info,
      resetProps = _objectWithoutProperties(_ref, _excluded);

  var tabs = [{
    value: '实时预警信息',
    key: TABS_BASE,
    content: /*#__PURE__*/_react["default"].createElement(_base["default"], {
      info: info
    })
  }, {
    value: '历史预警记录',
    key: TABS_HISTORY,
    content: /*#__PURE__*/_react["default"].createElement(_historyList["default"], {
      info: info
    })
  }];
  var equipmentName = info.equipmentName,
      statusStr = info.statusStr,
      status = info.status;

  var headerExt = /*#__PURE__*/_react["default"].createElement("span", {
    className: "handle-text ".concat(status === 'YCL' ? 'handle' : '')
  }, statusStr);

  return /*#__PURE__*/_react["default"].createElement(_vmGasModal["default"], _extends({
    title: equipmentName
  }, resetProps, {
    tabs: tabs,
    headerExt: headerExt,
    className: "alarm-modal",
    subtitle: ""
  }));
};

var VtxGasAlarmModal = function VtxGasAlarmModal(props) {
  var label = props.label,
      info = props.info;

  var _useModal = (0, _useModal2["default"])(),
      showModal = _useModal.showModal,
      modalProps = _objectWithoutProperties(_useModal, _excluded2);

  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, label ? /*#__PURE__*/_react["default"].createElement("a", {
    type: "link",
    onClick: showModal
  }, label) : /*#__PURE__*/_react["default"].createElement("span", null, "-"), modalProps.visible && /*#__PURE__*/_react["default"].createElement(Modal, _extends({}, modalProps, {
    info: info
  })));
};

Modal.propTypes = {
  info: _propTypes["default"].object
};
VtxGasAlarmModal.propTypes = {
  label: _propTypes["default"].string.isRequired,
  info: _propTypes["default"].object
};
VtxGasAlarmModal.Modal = Modal;
var _default = VtxGasAlarmModal;
exports["default"] = _default;
//# sourceMappingURL=index.js.map
