"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;
var _react = _interopRequireDefault(require("react"));
var _moment = _interopRequireDefault(require("moment"));
var _utils = require("@vtx/utils");
var _vmInfoCollection = _interopRequireDefault(require("../../../vm-info-collection"));
var _config = require("../../config");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
var Left = function Left(_ref) {
  var classPrefix = _ref.classPrefix,
    basicInfo = _ref.basicInfo,
    garbageNames = _ref.garbageNames;
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
  var fieldsData = _config.OverViewLeftFields.map(function (item) {
    return Object.assign(Object.assign({}, item), {
      value: basicInfo === null || basicInfo === void 0 ? void 0 : basicInfo[item.key]
    });
  });
  function inTimeRange(startTime, endTime) {
    var starts = startTime.split(':');
    var ends = endTime.split(':');
    var flag = false;
    if ((0, _moment["default"])().hour() >= parseInt(starts[0]) && (0, _moment["default"])().hour() <= parseInt(ends[0])) {
      flag = true;
      return flag;
    }
    if ((0, _moment["default"])().hour() === parseInt(starts[0]) && (0, _moment["default"])().hour() === parseInt(ends[0])) {
      if ((0, _moment["default"])().minute() >= parseInt(starts[1]) && (0, _moment["default"])().minute() <= parseInt(ends[1])) {
        flag = true;
        return flag;
      }
    }
    if ((0, _moment["default"])().hour() === parseInt(starts[0]) && (0, _moment["default"])().hour() === parseInt(ends[0]) && (0, _moment["default"])().minute() === parseInt(starts[1]) && (0, _moment["default"])().minute() === parseInt(ends[1])) {
      if ((0, _moment["default"])().second() >= parseInt(starts[2]) && (0, _moment["default"])().second() <= parseInt(ends[2])) {
        flag = true;
        return flag;
      }
    }
    return flag;
  }
  // 投放时间
  var getStatus = function getStatus(list) {
    var minutes = 0,
      start = '',
      end = '';
    var date = (0, _moment["default"])().format('YYYY-MM-DD');
    (list === null || list === void 0 ? void 0 : list.length) && list.map(function (ite) {
      var flag = inTimeRange(ite.startTime, ite.endTime);
      if (flag) {
        minutes = ((0, _moment["default"])((0, _moment["default"])("".concat(date, " ").concat(ite.endTime))).valueOf() - (0, _moment["default"])().valueOf()) / 1000 / 60;
        start = ite.startTime;
        end = ite.endTime;
      }
    });
    if (minutes > 0 && minutes <= 30) {
      return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("span", null, "\u5F00\u653E\u4E2D | "), /*#__PURE__*/_react["default"].createElement("span", null, minutes.toFixed(0), "\u5206\u949F\u540E\u5173\u95ED"), /*#__PURE__*/_react["default"].createElement("span", null, "(", start, " ", end, ")"));
    }
    if (minutes > 30) {
      return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("span", null, "\u5F00\u653E\u4E2D"));
    }
    return /*#__PURE__*/_react["default"].createElement("span", null, "\u5DF2\u5173\u95ED");
  };
  return /*#__PURE__*/_react["default"].createElement("div", {
    className: "".concat(classPrefix, "-left")
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "".concat(classPrefix, "-left-title")
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "".concat(classPrefix, "-left-title1")
  }, /*#__PURE__*/_react["default"].createElement("span", null, (basicInfo === null || basicInfo === void 0 ? void 0 : basicInfo.pointTypeDesc) || '', " "), /*#__PURE__*/_react["default"].createElement("img", {
    width: 17,
    height: 17,
    src: require('../../imgs/point.png')
  }), (basicInfo === null || basicInfo === void 0 ? void 0 : basicInfo.hasOffline) ? /*#__PURE__*/_react["default"].createElement("span", null, " \u5728\u7EBF") : /*#__PURE__*/_react["default"].createElement("span", null, " \u79BB\u7EBF")), /*#__PURE__*/_react["default"].createElement("div", {
    className: "".concat(classPrefix, "-left-title2")
  }, getStatus(basicInfo === null || basicInfo === void 0 ? void 0 : basicInfo.throwPeriods))), /*#__PURE__*/_react["default"].createElement("div", {
    className: "".concat(classPrefix, "-left-img")
  }, ((_a = basicInfo === null || basicInfo === void 0 ? void 0 : basicInfo.photo) === null || _a === void 0 ? void 0 : _a.length) ? (/*#__PURE__*/_react["default"].createElement("img", {
    width: 320,
    height: 250,
    src: "/cloudFile/common/downloadFile?id=".concat((_b = JSON.parse(basicInfo.photo || '[]')[0]) === null || _b === void 0 ? void 0 : _b.id, "&token=").concat((0, _utils.getVtxToken)('token'))
  })) : (/*#__PURE__*/_react["default"].createElement("img", {
    width: 320,
    height: 250,
    src: require("../../imgs/".concat((basicInfo === null || basicInfo === void 0 ? void 0 : basicInfo.pointType) === 'SMART_CLEAN_HOUSE' ? 'toukou' : (basicInfo === null || basicInfo === void 0 ? void 0 : basicInfo.pointType) === 'OPEN_CLEAN_HOUSE' ? 'fangzi' : 'tingzi', ".gif"))
  }))), /*#__PURE__*/_react["default"].createElement("div", {
    className: "".concat(classPrefix, "-left-middle")
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "".concat(classPrefix, "-left-item1")
  }, /*#__PURE__*/_react["default"].createElement("span", null, "\u6EE1\u6EA2"), /*#__PURE__*/_react["default"].createElement("span", null, /*#__PURE__*/_react["default"].createElement("span", {
    className: "".concat(classPrefix, "-left-item1-big")
  }, ((_c = basicInfo === null || basicInfo === void 0 ? void 0 : basicInfo.throwAberrantStatistics) === null || _c === void 0 ? void 0 : _c.overflow.happeningCount) || 0), "/", ((_d = basicInfo === null || basicInfo === void 0 ? void 0 : basicInfo.throwAberrantStatistics) === null || _d === void 0 ? void 0 : _d.overflow.todayCount) || 0, "\u4EF6")), /*#__PURE__*/_react["default"].createElement("div", {
    className: "".concat(classPrefix, "-left-item2")
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "".concat(classPrefix, "-left-item3")
  }, /*#__PURE__*/_react["default"].createElement("span", null, (garbageNames === null || garbageNames === void 0 ? void 0 : garbageNames.rightTimeName) || '-'), /*#__PURE__*/_react["default"].createElement("span", null, /*#__PURE__*/_react["default"].createElement("span", {
    className: "".concat(classPrefix, "-left-item1-big")
  }, ((_e = basicInfo === null || basicInfo === void 0 ? void 0 : basicInfo.throwAberrantStatistics) === null || _e === void 0 ? void 0 : _e.rightTimeOut.happeningCount) || 0), "/", ((_f = basicInfo === null || basicInfo === void 0 ? void 0 : basicInfo.throwAberrantStatistics) === null || _f === void 0 ? void 0 : _f.rightTimeOut.todayCount) || 0, "\u4EF6")), /*#__PURE__*/_react["default"].createElement("div", {
    className: "".concat(classPrefix, "-left-item4")
  }, /*#__PURE__*/_react["default"].createElement("span", null, (garbageNames === null || garbageNames === void 0 ? void 0 : garbageNames.wrongTimeName) || '-'), /*#__PURE__*/_react["default"].createElement("span", null, /*#__PURE__*/_react["default"].createElement("span", {
    className: "".concat(classPrefix, "-left-item1-big")
  }, ((_g = basicInfo === null || basicInfo === void 0 ? void 0 : basicInfo.throwAberrantStatistics) === null || _g === void 0 ? void 0 : _g.wrongTimeOut.happeningCount) || 0), "/", ((_h = basicInfo === null || basicInfo === void 0 ? void 0 : basicInfo.throwAberrantStatistics) === null || _h === void 0 ? void 0 : _h.wrongTimeOut.todayCount) || 0, "\u4EF6")), /*#__PURE__*/_react["default"].createElement("div", {
    className: "".concat(classPrefix, "-left-item5")
  }, /*#__PURE__*/_react["default"].createElement("span", null, (garbageNames === null || garbageNames === void 0 ? void 0 : garbageNames.trashBagName) || '-'), /*#__PURE__*/_react["default"].createElement("span", null, /*#__PURE__*/_react["default"].createElement("span", {
    className: "".concat(classPrefix, "-left-item1-big")
  }, ((_j = basicInfo === null || basicInfo === void 0 ? void 0 : basicInfo.throwAberrantStatistics) === null || _j === void 0 ? void 0 : _j.trashBag.happeningCount) || 0), "/", ((_k = basicInfo === null || basicInfo === void 0 ? void 0 : basicInfo.throwAberrantStatistics) === null || _k === void 0 ? void 0 : _k.trashBag.todayCount) || 0, "\u4EF6")), /*#__PURE__*/_react["default"].createElement("div", {
    className: "".concat(classPrefix, "-left-item6")
  }, /*#__PURE__*/_react["default"].createElement("span", null, (garbageNames === null || garbageNames === void 0 ? void 0 : garbageNames.mixedThrowName) || '-'), /*#__PURE__*/_react["default"].createElement("span", null, /*#__PURE__*/_react["default"].createElement("span", {
    className: "".concat(classPrefix, "-left-item1-big")
  }, ((_l = basicInfo === null || basicInfo === void 0 ? void 0 : basicInfo.throwAberrantStatistics) === null || _l === void 0 ? void 0 : _l.mixedThrow.happeningCount) || 0), "/", ((_m = basicInfo === null || basicInfo === void 0 ? void 0 : basicInfo.throwAberrantStatistics) === null || _m === void 0 ? void 0 : _m.mixedThrow.todayCount) || 0, "\u4EF6")))), /*#__PURE__*/_react["default"].createElement("div", {
    className: "".concat(classPrefix, "-left-info")
  }, /*#__PURE__*/_react["default"].createElement(_vmInfoCollection["default"], {
    data: fieldsData,
    gap: 16
  })));
};
var _default = exports["default"] = Left;
//# sourceMappingURL=Left.js.map
