"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = exports.SummaryItem = void 0;
var _react = _interopRequireDefault(require("react"));
var _moment = _interopRequireDefault(require("moment"));
var _vmSubTitle = _interopRequireDefault(require("../../../vm-sub-title"));
var _api = require("../../api");
var _RightBottom = require("./RightBottom");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
var SummaryItem = exports.SummaryItem = function SummaryItem(_ref) {
  var icon = _ref.icon,
    name = _ref.name,
    unit = _ref.unit,
    num = _ref.num;
  return /*#__PURE__*/_react["default"].createElement("div", {
    className: "summary-item"
  }, /*#__PURE__*/_react["default"].createElement("img", {
    src: icon
  }), /*#__PURE__*/_react["default"].createElement("div", {
    className: "summary-item-text"
  }, /*#__PURE__*/_react["default"].createElement("p", null, name), /*#__PURE__*/_react["default"].createElement("p", null, /*#__PURE__*/_react["default"].createElement("span", null, num), unit)));
};
var TopItem = function TopItem(_ref2) {
  var name = _ref2.name,
    content = _ref2.content,
    icon = _ref2.icon,
    textStyleType = _ref2.textStyleType;
  return /*#__PURE__*/_react["default"].createElement("div", {
    className: "top-item"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "img"
  }, /*#__PURE__*/_react["default"].createElement("p", {
    className: "name--".concat(textStyleType)
  }, name), /*#__PURE__*/_react["default"].createElement("img", {
    src: icon
  })), /*#__PURE__*/_react["default"].createElement("div", {
    className: "statistic"
  }, content.map(function (item) {
    return /*#__PURE__*/_react["default"].createElement("div", {
      key: item.text,
      style: {
        width: 240
      }
    }, /*#__PURE__*/_react["default"].createElement("span", null, item.text), /*#__PURE__*/_react["default"].createElement("span", {
      className: "statistic-value--".concat(textStyleType)
    }, item.value));
  })));
};
var Manage = function Manage(_ref3) {
  var classPrefix = _ref3.classPrefix,
    id = _ref3.id;
  var data = _api.overViewService.managementData({
    housingEstateId: id
  });
  var businessPackages = (0, _api.getDivisionBusinessPackages)(id) || [];
  // 今日已过时常
  var todayPastHour = Number((((0, _moment["default"])().valueOf() - (0, _moment["default"])().startOf('day').valueOf()) / 1000 / 60 / 60).toFixed(1));
  var cleanGroundDuration = (data === null || data === void 0 ? void 0 : data.dirtyGroundDuration) ? (todayPastHour - (data === null || data === void 0 ? void 0 : data.dirtyGroundDuration) / 60).toFixed(1) : 0;
  var noOverflowDuration = (data === null || data === void 0 ? void 0 : data.overflowDuration) ? (todayPastHour - (data === null || data === void 0 ? void 0 : data.overflowDuration) / 60).toFixed(1) : 0;
  return /*#__PURE__*/_react["default"].createElement("div", {
    className: "".concat(classPrefix, "-manage")
  }, /*#__PURE__*/_react["default"].createElement(_vmSubTitle["default"], {
    title: "\u8FD0\u8425\u7BA1\u7406"
  }), /*#__PURE__*/_react["default"].createElement("div", {
    className: "".concat(classPrefix, "-manage-top"),
    style: businessPackages.includes('THROW') ? {
      flexDirection: 'column'
    } : {}
  }, /*#__PURE__*/_react["default"].createElement(TopItem, {
    name: "\u73AF\u5883\u7BA1\u7406\u6210\u6548",
    icon: require('../../imgs/manage-hjgl.png'),
    textStyleType: 1,
    content: [].concat(_toConsumableArray(businessPackages.includes('LANDING') ? [{
      text: '今日地面干净时长占比',
      value: "".concat(cleanGroundDuration, "h/").concat(todayPastHour, "h")
    }] : []), _toConsumableArray(businessPackages.includes('OVERFLOW') ? [{
      text: '今日无爆桶状态时长占比',
      value: "".concat(noOverflowDuration, "h/").concat(todayPastHour, "h")
    }] : []))
  }), /*#__PURE__*/_react["default"].createElement(TopItem, {
    name: "\u516C\u4F17\u5BA3\u6559\u6210\u6548",
    icon: require('../../imgs/manage-gzcx.png'),
    textStyleType: 2,
    content: [].concat(_toConsumableArray(businessPackages.includes('CHUYU_QUALITY') ? [{
      text: '厨余准确率',
      value: "".concat((0, _RightBottom.getPercent)(data === null || data === void 0 ? void 0 : data.chuyuAccuracy), "%")
    }] : []), _toConsumableArray(businessPackages.includes('IDENTIFICATION') ? [{
      text: '居民参与率',
      value: "".concat((0, _RightBottom.getPercent)(data === null || data === void 0 ? void 0 : data.personParticipationRate), "%")
    }] : []))
  })), /*#__PURE__*/_react["default"].createElement("div", {
    className: "".concat(classPrefix, "-manage-bottom")
  }, /*#__PURE__*/_react["default"].createElement(SummaryItem, {
    icon: require('../../imgs/manage-yyxj.png'),
    name: "\u8BED\u97F3\u5BA3\u6559",
    unit: "\u6B21",
    num: (data === null || data === void 0 ? void 0 : data.voiceEducateTimes) || 0
  }), businessPackages.includes('IDENTIFICATION') && (/*#__PURE__*/_react["default"].createElement(SummaryItem, {
    icon: require('../../imgs/manage-wgmsr.png'),
    name: "\u8FDD\u89C4\u964C\u751F\u4EBA",
    unit: "\u4EBA",
    num: (data === null || data === void 0 ? void 0 : data.strangerNum) || 0
  })), businessPackages.includes('IDENTIFICATION') && (/*#__PURE__*/_react["default"].createElement(SummaryItem, {
    icon: require('../../imgs/manage-hmd.png'),
    name: "\u7070\u540D\u5355",
    unit: "\u4EBA",
    num: (data === null || data === void 0 ? void 0 : data.badLabelPersonNum) || 0
  }))));
};
var _default = exports["default"] = Manage;
//# sourceMappingURL=Manage.js.map
