import { useMemo } from 'react';
import VmCustom from "../_components/vm-custom";
import useGetConfig from "../_hooks/useGetConfig";
import VtxBaseModal from "../vtx-base-modal";
import { overViewService, useGetLoadEnumValue } from "./api";
import { Alarm, OverView, TFRD, WGGS, WGXW } from "./components";
import { jsx as _jsx } from "react/jsx-runtime";
var VtxHousingEstateModal = function VtxHousingEstateModal(props) {
  var _props$visible = props.visible,
    visible = _props$visible === void 0 ? false : _props$visible,
    onCancel = props.onCancel,
    _props$theme = props.theme,
    theme = _props$theme === void 0 ? '' : _props$theme,
    id = props.id,
    _props$title = props.title,
    title = _props$title === void 0 ? '' : _props$title;
  var PREFIX = 'estate';
  var tabs = [{
    key: 'base',
    title: '总览信息'
  }, {
    key: 'wgrgs',
    title: '违规人公示'
  }, {
    key: 'tfrd',
    title: '居民投放热度'
  }, {
    key: 'wgxw',
    title: '居民违规行为'
  }, {
    key: 'alarm',
    title: '报警事件分析'
  }];
  var _useGetConfig = useGetConfig('estate', tabs),
    tabsData = _useGetConfig.tabsData;
  // 小区基本信息
  var basicInfo = overViewService.useEstateStatistics({
    housingEstateId: id
  });
  // 系统配置获取垃圾类型配置的图标
  var garbageIcons = overViewService.useGetGarbageIcons();
  // 小区关联投放点
  var throwPoints = overViewService.useThrowPoints({
    housingEstateId: id
  });
  // 小区业务包code
  var serviceList = useGetLoadEnumValue(id) || [];
  var tabsList = useMemo(function () {
    var tabsList = tabsData;
    if (!serviceList.includes('THROW')) {
      tabsList = tabsList.filter(function (ele) {
        return ele.key !== 'tfrd';
      });
    }
    return tabsList;
  }, [JSON.stringify(tabsData), JSON.stringify(serviceList)]);
  var tabContents = {
    base: /*#__PURE__*/_jsx(OverView, {
      classPrefix: PREFIX,
      id: id,
      basicInfo: basicInfo,
      throwPoints: throwPoints,
      serviceList: serviceList,
      garbageIcons: garbageIcons
    }),
    wgrgs: /*#__PURE__*/_jsx(WGGS, {
      classPrefix: PREFIX,
      id: id,
      throwPoints: throwPoints,
      serviceList: serviceList
    }),
    tfrd: /*#__PURE__*/_jsx(TFRD, {
      classPrefix: PREFIX,
      id: id
    }),
    alarm: /*#__PURE__*/_jsx(Alarm, {
      classPrefix: PREFIX,
      id: id
    }),
    wgxw: /*#__PURE__*/_jsx(WGXW, {
      classPrefix: PREFIX,
      id: id,
      throwPoints: throwPoints,
      serviceList: serviceList
    })
  };
  // 自定义页签可配置多个，
  if (tabsData !== null && tabsData !== void 0 && tabsData.length) {
    tabsData.forEach(function (ele) {
      if (ele.url) {
        tabContents[ele.key] = /*#__PURE__*/_jsx(VmCustom, {
          id: id,
          url: ele === null || ele === void 0 ? void 0 : ele.url
        });
      }
    });
  }
  return /*#__PURE__*/_jsx(VtxBaseModal, {
    title: title,
    theme: theme,
    width: 1344,
    tabs: tabs,
    contents: tabContents,
    visible: visible,
    onCancel: onCancel
  });
};
export default VtxHousingEstateModal;