function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
import { useMemo } from 'react';
import VmCustom from "../_components/vm-custom";
import VmRepairMaintain from "../_components/vm-repair-maintain";
import useGetChannels from "../_hooks/useGetChannels";
import useGetConfig from "../_hooks/useGetConfig";
import VtxBaseModal from "../vtx-base-modal";
import { BaseService as facilityService } from "../vtx-default-modal/api";
import { BaseService } from "./api";
import { AlarmInfo, BaseInfo, ExeceptionInfo, SyInfo } from "./components";
import "./style";
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
var TABS_BASE = 'base';
var TABS_SY = 'sy';
var TABS_WARNNING = 'warning';
var TABS_EXECEPTION = 'exeception';
var TABS_RM = 'default-rm';
var TABS_VIDEO = 'video';
var VtxCpModal = function VtxCpModal(props) {
  var id = props.id,
    title = props.title,
    subTitle = props.subTitle,
    theme = props.theme,
    source = props.source,
    startDate = props.startDate,
    endDate = props.endDate,
    visible = props.visible,
    onCancel = props.onCancel,
    tabChose = props.tabChose;
  var tabs = [{
    key: TABS_BASE,
    title: '总览信息'
  }, {
    key: TABS_SY,
    title: '收运信息'
  }, {
    key: TABS_WARNNING,
    title: '报警信息'
  }, {
    key: TABS_EXECEPTION,
    title: '异常信息'
  }];
  var _BaseService$useBaseD = BaseService.useBaseDetail(id, 'wgs84'),
    info = _BaseService$useBaseD.info,
    baseInfo = _BaseService$useBaseD.baseInfo,
    rules = _BaseService$useBaseD.rules;
  var _facilityService$useG = facilityService.useGetFacConfig('cp'),
    facConfig = _facilityService$useG.facConfig;
  var _useGetConfig = useGetConfig('cp', tabs),
    tabsData = _useGetConfig.tabsData;
  var _useGetChannels = useGetChannels("".concat(info === null || info === void 0 ? void 0 : info.collectPointTypeCode, "_").concat(info === null || info === void 0 ? void 0 : info.code), !!(info !== null && info !== void 0 && info.collectPointTypeCode)),
    channels = _useGetChannels.channels;
  var tabsList = useMemo(function () {
    var _facConfig$data;
    var tabsList = tabsData;
    if (!(facConfig !== null && facConfig !== void 0 && (_facConfig$data = facConfig.data) !== null && _facConfig$data !== void 0 && _facConfig$data.beenCollect)) {
      tabsList = tabsList.filter(function (ele) {
        return !['cp-sy', 'cp-warning', 'cp-exeception'].includes(ele.key);
      });
    }
    if (tabsList.findIndex(function (ele) {
      return ele.key === 'cp-video';
    }) > -1) {
      if ((channels === null || channels === void 0 ? void 0 : channels.length) < 1) {
        tabsList = tabsList.filter(function (ele) {
          return ele.key !== 'cp-video';
        });
      }
    }
    return tabsList;
  }, [JSON.stringify(tabsData), JSON.stringify(channels), JSON.stringify(facConfig)]);
  var contents = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, TABS_BASE, /*#__PURE__*/_jsx(BaseInfo, {
    id: id,
    baseInfo: baseInfo,
    info: info,
    rules: rules
  })), TABS_SY, /*#__PURE__*/_jsx(SyInfo, {
    id: id
  })), TABS_WARNNING, /*#__PURE__*/_jsx(AlarmInfo, {
    id: id
  })), TABS_EXECEPTION, /*#__PURE__*/_jsx(ExeceptionInfo, {
    id: id
  })), TABS_RM, /*#__PURE__*/_jsx(VmRepairMaintain, {
    id: id
  }));
  // 自定义页签可配置多个，包含custom即可
  if (tabsData !== null && tabsData !== void 0 && tabsData.length) {
    tabsData.forEach(function (ele) {
      if (ele.url) {
        contents[ele.key] = /*#__PURE__*/_jsx(VmCustom, {
          id: id,
          url: ele === null || ele === void 0 ? void 0 : ele.url
        });
      }
    });
  }
  return /*#__PURE__*/_jsx(_Fragment, {
    children: visible && /*#__PURE__*/_jsx(VtxBaseModal, {
      id: id,
      type: "facility",
      source: source,
      title: title,
      subTitle: subTitle,
      width: 1250,
      top: 10,
      theme: theme,
      startDate: startDate,
      endDate: endDate,
      visible: visible,
      onCancel: onCancel,
      tabs: tabsList,
      tabChose: tabChose,
      contents: contents
    })
  });
};
export default VtxCpModal;