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); }
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 { VtxImage } from '@vtx/components';
import '@vtx/components/lib/vtx-image/style/index';
import { getVtxToken, request } from '@vtx/utils';
import { useEffect, useState } from 'react';
import { VmEmpty, VmMap } from "../../../_components";
import Sjjg from "./Sjjg";

//基础设施详情
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
var getJcssDetail = function getJcssDetail(params) {
  return request.get('/cloud/jcss-reborn/facility/get', {
    data: params
  });
};
export default (function (props) {
  var _gcDetail$geometryInf, _gcDetail$geometryInf2, _gcDetail$geometryInf3, _gcDetail$geometryInf4;
  var theme = props.theme,
    gcDetail = props.gcDetail,
    fields = props.fields;
  var _useState = useState([]),
    _useState2 = _slicedToArray(_useState, 2),
    imgList = _useState2[0],
    setImgList = _useState2[1];
  useEffect(function () {
    if (gcDetail.id) {
      if (gcDetail.photoIds) {
        setImgList(JSON.parse(gcDetail.photoIds).map(function (item, index) {
          return _objectSpread(_objectSpread({}, item), {}, {
            index: index + 1,
            name: item.name.split('.')[0],
            url: "/vortex/rest/cloud/np/file/downloadFileThumbnail/".concat(item.id, "?token=").concat(getVtxToken('token'), "&outputQuality=0.5&scale=0.5")
          });
        }));
      } else {
        getJcssDetail({
          id: gcDetail.id,
          coordType: 'bd09'
        }).then(function (res) {
          if ((res === null || res === void 0 ? void 0 : res.result) === 0) {
            setImgList(res.data.typePhotoIds ? JSON.parse(res.data.typePhotoIds).map(function (item, index) {
              return _objectSpread(_objectSpread({}, item), {}, {
                index: index + 1,
                name: item.name.split('.')[0],
                url: "/vortex/rest/cloud/np/file/downloadFileThumbnail/".concat(item.id, "?token=").concat(getVtxToken('token'), "&outputQuality=0.5&scale=0.5")
              });
            }) : []);
          }
        });
      }
    }
  }, [gcDetail]);
  var isShow = function isShow(key) {
    return fields.filter(function (item) {
      return item.key === key;
    }).length !== 0;
  };
  var basicList = [{
    name: '行政区划',
    key: 'divisionName',
    isShow: isShow('divisionId')
  }, {
    name: '开放时间',
    key: 'openTime',
    isShow: isShow('openhour')
  }, {
    name: '权属单位',
    key: 'belongUnitName',
    isShow: isShow('qsdwId')
  }, {
    name: '权属单位联系人',
    key: 'belongUnitContract',
    isShow: isShow('qsdwlxrId')
  }, {
    name: '权属单位联系电话',
    key: 'belongUnitContractWay',
    isShow: isShow('qsdwlxdhId')
  }, {
    name: '运营单位',
    key: 'runUnitName',
    isShow: isShow('yydwId')
  }, {
    name: '运营单位联系人',
    key: 'runUnitContract',
    isShow: isShow('yydwlxrId')
  }, {
    name: '运营单位联系电话',
    key: 'runUnitContractWay',
    isShow: isShow('yydwlxdhId')
  }, {
    name: '管理类型',
    key: 'manageType',
    isShow: isShow('managementtypeName')
  }, {
    name: '保洁形式',
    key: 'manageMethod',
    isShow: isShow('bjxsName')
  }, {
    name: '保洁员',
    key: 'cleaner',
    isShow: isShow('bjyId')
  }, {
    name: '保洁时间',
    key: 'cleanTime',
    isShow: isShow('bjsjId')
  }, {
    name: '详细地址',
    key: 'address',
    isShow: isShow('address')
  }];
  return /*#__PURE__*/_jsxs("div", {
    className: "wr-base-inner",
    children: [/*#__PURE__*/_jsx("div", {
      className: "wr-base-img",
      children: imgList.length ? /*#__PURE__*/_jsx(VtxImage.PreviewGroup, {
        children: imgList.map(function (item, index) {
          return /*#__PURE__*/_jsx(VtxImage, {
            src: item.url,
            alt: item.name,
            style: {
              display: index === 0 ? 'block' : 'none',
              width: '100%',
              height: '100%'
            }
          }, item.id);
        })
      }) : /*#__PURE__*/_jsx(VmEmpty, {
        type: "NO_PICTURE"
      })
    }), /*#__PURE__*/_jsxs("div", {
      className: "wr-base-info",
      children: [basicList.filter(function (item) {
        return item.isShow;
      }).map(function (item) {
        return /*#__PURE__*/_jsxs("div", {
          title: gcDetail[item.key],
          children: [/*#__PURE__*/_jsxs("span", {
            style: {
              color: theme === 'light' ? '#8C8C8C' : '#2FACFF'
            },
            children: [item.name, "\uFF1A"]
          }), gcDetail[item.key] || '--']
        }, item.key);
      }), isShow('address') && ((_gcDetail$geometryInf = gcDetail.geometryInfo) === null || _gcDetail$geometryInf === void 0 ? void 0 : _gcDetail$geometryInf.lngLats) && /*#__PURE__*/_jsx("div", {
        className: "wr-map",
        children: /*#__PURE__*/_jsx(VmMap, {
          mapCenter: (_gcDetail$geometryInf2 = gcDetail.geometryInfo) === null || _gcDetail$geometryInf2 === void 0 ? void 0 : _gcDetail$geometryInf2.lngLats.split(','),
          mapType: "bmap",
          geometryType: "point",
          mapPoints: [{
            id: 'wrPoint',
            name: 'wrPoint',
            lng: (_gcDetail$geometryInf3 = gcDetail.geometryInfo) === null || _gcDetail$geometryInf3 === void 0 ? void 0 : _gcDetail$geometryInf3.lngLats.split(',')[0],
            lat: (_gcDetail$geometryInf4 = gcDetail.geometryInfo) === null || _gcDetail$geometryInf4 === void 0 ? void 0 : _gcDetail$geometryInf4.lngLats.split(',')[1],
            icon: 'HW_GC'
          }]
        })
      })]
    }), /*#__PURE__*/_jsx("div", {
      className: "divider"
    }), gcDetail.hasDevice && /*#__PURE__*/_jsxs(_Fragment, {
      children: [/*#__PURE__*/_jsxs("div", {
        className: "wr-base-subTitle",
        children: [/*#__PURE__*/_jsx("div", {
          className: "wr-base-subTip"
        }), /*#__PURE__*/_jsx("div", {
          className: "wr-base-subText",
          children: "\u6570\u636E\u76D1\u7BA1"
        })]
      }), /*#__PURE__*/_jsx(Sjjg, _objectSpread({}, props))]
    })]
  });
});