function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
import { request } from '@vtx/utils';
import { useSetState } from 'ahooks';
import { useEffect } from 'react';
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
var readData = function readData(params) {
  return request.get('/cloud/zhgc-reborn/api/gis/pop/readData', {
    data: params
  });
};
export default (function (props) {
  var theme = props.theme,
    gcDetail = props.gcDetail;
  var _useSetState = useSetState({
      all: [],
      male: [],
      female: [],
      third: [],
      unisex: []
    }),
    _useSetState2 = _slicedToArray(_useSetState, 2),
    monitorDetail = _useSetState2[0],
    setMonitorDetail = _useSetState2[1];
  useEffect(function () {
    gcDetail.id && readData({
      id: gcDetail.id
    }).then(function (res) {
      if ((res === null || res === void 0 ? void 0 : res.result) === 0) {
        setMonitorDetail({
          all: res.data.all || [],
          male: res.data.male || [],
          female: res.data.female || [],
          third: res.data.third || [],
          unisex: res.data.unisex || []
        });
      }
    });
  }, [gcDetail]);
  var totalList = [{
    name: '用水量',
    img: require("./assets/".concat(theme, "/ysl.png")),
    section: monitorDetail.all.filter(function (item) {
      return item.factorCode === 'WATER_USE';
    })[0],
    unit: '吨'
  }, {
    name: '用电量',
    img: require("./assets/".concat(theme, "/ydl.png")),
    section: monitorDetail.all.filter(function (item) {
      return item.factorCode === 'ELEC_USE';
    })[0],
    unit: '度'
  }];
  var eachList = [{
    name: '男厕',
    img: 'male',
    bgB: 'rgba(51, 166, 255, 0.2)',
    bg: '#F3F8FF',
    list: monitorDetail.male
  }, {
    name: '女厕',
    img: 'female',
    bgB: 'rgba(255,152,175,0.2)',
    bg: '#FFF2F5',
    list: monitorDetail.female
  }, {
    name: '第三卫生间',
    img: 'dswsj',
    bgB: 'rgba(84,247,165,0.2)',
    bg: '#F0F9F4',
    list: monitorDetail.third
  }, {
    name: '通用卫生间',
    img: 'tywsj',
    bgB: 'rgba(255,203,105,0.2)',
    bg: '#FFF9EF',
    list: monitorDetail.unisex
  }];
  var getImg = function getImg(code) {
    switch (code) {
      case 'PERSON_NUM':
        return 'rll';
      case 'TEMPERATURE':
        return 'wd';
      case 'HUMIDITY':
        return 'sd';
      case 'ODOR':
        return 'cq';
      case 'HYDROGEN':
        return 'lhq';
      case 'AMMONIA':
        return 'aq';
      default:
        return 'ty';
    }
  };
  return /*#__PURE__*/_jsxs(_Fragment, {
    children: [!!totalList.filter(function (item) {
      return item.section;
    }).length && /*#__PURE__*/_jsx("div", {
      className: "wr-sjjg-total",
      children: totalList.filter(function (item) {
        return item.section;
      }).map(function (item) {
        return /*#__PURE__*/_jsxs("div", {
          className: "sjjg-total-each",
          children: [/*#__PURE__*/_jsx("img", {
            src: item.img,
            alt: "ysl"
          }), /*#__PURE__*/_jsxs("div", {
            children: [/*#__PURE__*/_jsx("div", {
              children: item.name
            }), /*#__PURE__*/_jsxs("div", {
              children: [item.section, "\u2002", item.unit]
            })]
          })]
        }, item.name);
      })
    }), /*#__PURE__*/_jsx("div", {
      className: "wr-sjjg-each",
      children: eachList.filter(function (item) {
        return !!item.list.length;
      }).map(function (item) {
        return /*#__PURE__*/_jsxs("div", {
          className: "sjjg-each-item",
          style: {
            background: theme === 'blue' ? item.bgB : item.bg
          },
          children: [/*#__PURE__*/_jsxs("div", {
            className: "each-item-title",
            children: [/*#__PURE__*/_jsx("img", {
              src: require("./assets/".concat(theme, "/").concat(item.img, ".png")),
              alt: item.img
            }), item.name]
          }), /*#__PURE__*/_jsx("div", {
            className: "each-item-value",
            children: item.list.map(function (each) {
              var _each$value, _each$unit;
              return /*#__PURE__*/_jsxs("div", {
                className: "each-value",
                title: "\u6700\u8FD1\u66F4\u65B0\u65F6\u95F4\uFF1A".concat(each.dataTime || '--'),
                children: [/*#__PURE__*/_jsxs("div", {
                  className: "each-value-num",
                  children: [/*#__PURE__*/_jsx("span", {
                    style: {
                      fontSize: '18px'
                    },
                    children: each.factorCode === 'PERSON_NUM' && Number(each.value) ? Number(each.value).toFixed(0) : (_each$value = each.value) !== null && _each$value !== void 0 ? _each$value : '--'
                  }), "\xA0", (_each$unit = each.unit) !== null && _each$unit !== void 0 ? _each$unit : '--']
                }), /*#__PURE__*/_jsxs("div", {
                  className: "each-factor-value",
                  title: each.factorName || each.name,
                  children: [/*#__PURE__*/_jsx("img", {
                    src: require("./assets/".concat(theme, "/").concat(getImg(each.factorCode), ".png")),
                    alt: "rll"
                  }), each.factorName || each.name]
                })]
              }, each.factorName);
            })
          })]
        }, item.name);
      })
    })]
  });
});