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 ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
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, VmRepairMaintain, VmVideo } from "../_components";
import useGetChannels from "../_hooks/useGetChannels";
import useGetConfig from "../_hooks/useGetConfig";
import { CommonService } from "../_service";
import VtxBaseModal from "../vtx-base-modal";
import Metering from "../vtx-df-modal/components/Metering";
import Appraisal from "../vtx-kh-modal/components/Record";
import { BaseInfo } from "./components";
import "./style";
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
var TABS_BASE = 'base';
var TABS_APPRAISAL = 'appraisal';
var TABS_RM = 'rm';
var TABS_VIDEO = 'video';
var TABS_METERING = 'metering';
var VtxDefaultModal = function VtxDefaultModal(props) {
  var _info$geometryInfo, _info$geometryInfo2, _info$geometryInfo3;
  var id = props.id,
    title = props.title,
    subTitle = props.subTitle,
    theme = props.theme,
    visible = props.visible,
    startDate = props.startDate,
    endDate = props.endDate,
    onCancel = props.onCancel,
    mapCenter = props.mapCenter,
    mapPoints = props.mapPoints,
    source = props.source,
    customMapInfo = props.customMapInfo,
    tabChose = props.tabChose,
    showCollect = props.showCollect;
  var tabs = [{
    key: TABS_BASE,
    title: '总览信息'
  }];
  var _CommonService$useBas = CommonService.useBaseInfo(id, (customMapInfo === null || customMapInfo === void 0 ? void 0 : customMapInfo.coordinate) || 'wgs84'),
    photos = _CommonService$useBas.photos,
    info = _CommonService$useBas.info;
  var _useGetConfig = useGetConfig(info === null || info === void 0 ? void 0 : info.typeCode, tabs),
    tabsData = _useGetConfig.tabsData;
  var _useGetChannels = useGetChannels("".concat(info === null || info === void 0 ? void 0 : info.typeCode, "_").concat(info === null || info === void 0 ? void 0 : info.code), !!(info !== null && info !== void 0 && info.typeCode) && (tabsData === null || tabsData === void 0 ? void 0 : tabsData.findIndex(function (ele) {
      return ele.key === 'video';
    })) > -1),
    channels = _useGetChannels.channels;
  var _CommonService$useLmD = CommonService.useLmDetail(id, (tabsData === null || tabsData === void 0 ? void 0 : tabsData.findIndex(function (ele) {
      return ele.key === 'metering';
    })) > -1),
    detail = _CommonService$useLmD.detail;
  var tabsList = useMemo(function () {
    var tabsList = tabsData;
    if (!(detail !== null && detail !== void 0 && detail.beenWeigh)) {
      tabsList = tabsList.filter(function (ele) {
        return ele.key !== 'metering';
      });
    }
    if (tabsList.findIndex(function (ele) {
      return ele.key === 'video';
    }) > -1) {
      if ((channels === null || channels === void 0 ? void 0 : channels.length) < 1) {
        tabsList = tabsList.filter(function (ele) {
          return ele.key !== 'video';
        });
      }
    }
    return tabsList;
  }, [JSON.stringify(tabsData), JSON.stringify(channels), JSON.stringify(detail)]);
  var param = {
    id: id,
    info: info,
    photos: photos,
    mapCenter: mapCenter,
    customMapInfo: customMapInfo,
    geometryType: info === null || info === void 0 || (_info$geometryInfo = info.geometryInfo) === null || _info$geometryInfo === void 0 ? void 0 : _info$geometryInfo.type,
    lineLayer: (info === null || info === void 0 || (_info$geometryInfo2 = info.geometryInfo) === null || _info$geometryInfo2 === void 0 ? void 0 : _info$geometryInfo2.type) !== 'point' ? {
      id: 'roadLine',
      rings: info === null || info === void 0 || (_info$geometryInfo3 = info.geometryInfo) === null || _info$geometryInfo3 === void 0 ? void 0 : _info$geometryInfo3.lngLats,
      config: {}
    } : undefined
  };
  var contents = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, TABS_BASE, /*#__PURE__*/_jsx(BaseInfo, _objectSpread(_objectSpread({}, param), {}, {
    mapPoints: mapPoints
  }))), TABS_APPRAISAL, /*#__PURE__*/_jsx(Appraisal, {
    id: id
  })), TABS_RM, /*#__PURE__*/_jsx(VmRepairMaintain, {
    id: id
  })), TABS_VIDEO, /*#__PURE__*/_jsx(VmVideo, {
    channels: channels
  })), TABS_METERING, /*#__PURE__*/_jsx(Metering, {
    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",
      title: title,
      subTitle: subTitle,
      width: 1200,
      height: 550,
      theme: theme,
      source: source,
      visible: visible,
      onCancel: onCancel,
      tabs: tabsList,
      tabChose: tabChose,
      startDate: startDate,
      endDate: endDate,
      showCollect: showCollect,
      contents: contents
    })
  });
};
export default VtxDefaultModal;