import { VtxImage } from '@vtx/components';
import { getVtxToken } from '@vtx/utils';
import { Spin } from 'antd';
import { VmEmpty } from "../../../_components";
import useSettings from "../../../_hooks/useSettings";
import { throwFailPersonService } from "../../api";
import "./index.less";
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
var WGGSContent = function WGGSContent(_ref) {
  var _ref$classPrefix = _ref.classPrefix,
    classPrefix = _ref$classPrefix === void 0 ? '' : _ref$classPrefix,
    id = _ref.id,
    startTime = _ref.startTime,
    endTime = _ref.endTime,
    _ref$throwPointId = _ref.throwPointId,
    throwPointId = _ref$throwPointId === void 0 ? '' : _ref$throwPointId;
  var _useSettings = useSettings(),
    isDark = _useSettings.isDark;
  var _throwFailPersonServi = throwFailPersonService.useGetList({
      housingEstateId: id,
      beginTime: startTime,
      endTime: endTime,
      throwPointId: throwPointId
    }),
    data = _throwFailPersonServi.data,
    loading = _throwFailPersonServi.loading;
  var _ref2 = data || {},
    _ref2$rows = _ref2.rows,
    rows = _ref2$rows === void 0 ? [] : _ref2$rows;
  return /*#__PURE__*/_jsx(_Fragment, {
    children: !rows.length && !loading ? /*#__PURE__*/_jsx("div", {
      style: {
        height: 500
      },
      children: /*#__PURE__*/_jsx(VmEmpty, {})
    }) : /*#__PURE__*/_jsxs(_Fragment, {
      children: [/*#__PURE__*/_jsx(Spin, {
        spinning: loading,
        className: "".concat(classPrefix, "-content-spin")
      }), /*#__PURE__*/_jsx("div", {
        className: "".concat(classPrefix, "-content ").concat(isDark ? 'dark' : ''),
        children: rows.map(function (item) {
          var _JSON$parse$, _tempDetectObjects$fi;
          var photoId = (_JSON$parse$ = JSON.parse(item.personPhoto2 || '[]')[0]) === null || _JSON$parse$ === void 0 ? void 0 : _JSON$parse$.id;
          var tempDetectObjects = JSON.parse(item.detectObjects || '[]');
          var photoAfterArr = (_tempDetectObjects$fi = tempDetectObjects.find(function (item) {
            return item.pic === 'dropPic2';
          })) === null || _tempDetectObjects$fi === void 0 ? void 0 : _tempDetectObjects$fi.info;
          var str = "/cloud/sdyd/markBox?fileId=".concat(photoId, "&detectObjects=").concat(photoAfterArr ? JSON.stringify(photoAfterArr) : '', "&token=").concat(getVtxToken('token'));
          return /*#__PURE__*/_jsxs("div", {
            className: "".concat(classPrefix, "-content-item"),
            children: [/*#__PURE__*/_jsx("div", {
              className: "".concat(classPrefix, "-content-item-img"),
              children: /*#__PURE__*/_jsx(VtxImage, {
                src: str
              })
            }), /*#__PURE__*/_jsx("p", {
              children: item.throwPointName
            })]
          }, item.throwFailId);
        })
      })]
    })
  });
};
export default WGGSContent;