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 { useSetState } from 'ahooks';
import dayjs from 'dayjs';
import * as echarts from 'echarts';
import { useEffect } from 'react';
import { VmEmpty, VmFilter, VmLineCharts, VmWrapper } from "../../../_components";
import useSettings from "../../../_hooks/useSettings";
import { BaseService } from "../../api";
import "./index.less";
import { jsx as _jsx } from "react/jsx-runtime";
function Jczbqs(props) {
  var _timeSumData$extraDat, _timeSumData$values;
  var _useSettings = useSettings(),
    chartFontColor = _useSettings.chartFontColor,
    theme = _useSettings.theme;
  var deviceId = props.deviceId,
    realtimeRes = props.realtimeRes;
  var _useSetState = useSetState({
      value: ''
    }),
    _useSetState2 = _slicedToArray(_useSetState, 2),
    state = _useSetState2[0],
    setState = _useSetState2[1];
  var value = state.value;
  useEffect(function () {
    var _realtimeRes$;
    setState({
      value: realtimeRes === null || realtimeRes === void 0 || (_realtimeRes$ = realtimeRes[0]) === null || _realtimeRes$ === void 0 ? void 0 : _realtimeRes$.monitorItemCode
    });
  }, [realtimeRes]);
  var _BaseService$useJczbq = BaseService.useJczbqsfx(value, deviceId, dayjs().subtract(24, 'hours').format('YYYY-MM-DD HH:mm:ss'), dayjs().format('YYYY-MM-DD HH:mm:ss')),
    timeSumData = _BaseService$useJczbq.timeSumData;
  return /*#__PURE__*/_jsx("div", {
    className: "df-overview-trend",
    children: /*#__PURE__*/_jsx(VmWrapper, {
      title: "\u76D1\u6D4B\u6307\u6807\u8D8B\u52BF\u5206\u6790\uFF0824\u5C0F\u65F6\uFF09",
      extra: /*#__PURE__*/_jsx(VmFilter.VMSelect, {
        value: value,
        onChange: function onChange(val) {
          setState({
            value: val
          });
        },
        options: realtimeRes === null || realtimeRes === void 0 ? void 0 : realtimeRes.map(function (item) {
          return {
            value: item.monitorItemCode,
            label: item.monitorItemName
          };
        }),
        style: {
          width: 150
        },
        placeholder: "\u8BF7\u9009\u62E9",
        allowClear: false
      }),
      children: /*#__PURE__*/_jsx("div", {
        className: "df-overview-trend-content",
        children: timeSumData ? /*#__PURE__*/_jsx(VmLineCharts, {
          title: '总数',
          height: 191,
          unit: (timeSumData === null || timeSumData === void 0 || (_timeSumData$extraDat = timeSumData.extraData) === null || _timeSumData$extraDat === void 0 || (_timeSumData$extraDat = _timeSumData$extraDat[0]) === null || _timeSumData$extraDat === void 0 ? void 0 : _timeSumData$extraDat.unit) || '',
          xAxis: (timeSumData === null || timeSumData === void 0 ? void 0 : timeSumData.names) || [],
          dataList: timeSumData === null || timeSumData === void 0 || (_timeSumData$values = timeSumData.values) === null || _timeSumData$values === void 0 ? void 0 : _timeSumData$values.map(function (ele, index) {
            var _timeSumData$extraDat2;
            return {
              data: ele,
              name: (timeSumData === null || timeSumData === void 0 || (_timeSumData$extraDat2 = timeSumData.extraData[index]) === null || _timeSumData$extraDat2 === void 0 ? void 0 : _timeSumData$extraDat2.monitorItemName) || '',
              smooth: true,
              areaStyle: {
                color: new echarts.graphic.LinearGradient(0, 1, 0, 0, [{
                  offset: 0,
                  color: theme === 'blue' ? 'rgba(0,157,255,0.1)' : 'rgba(22, 119, 255, 0.10)'
                }, {
                  offset: 0.5,
                  color: theme === 'blue' ? 'rgba(0,157,255,0.3)' : 'rgba(22, 119, 255, 0.30)'
                }, {
                  offset: 1,
                  color: theme === 'blue' ? 'rgba(0,157,255,0.75)' : 'rgba(22, 119, 255, 0.75)'
                }])
              }
            };
          })
        }) : /*#__PURE__*/_jsx(VmEmpty, {})
      })
    })
  });
}
export default Jczbqs;