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 { VtxImage } from '@vtx/components';
import { getVtxToken } from '@vtx/utils';
import { Carousel } from 'antd';
import { VmEmpty, VmInfoCollection, VmMap, VmWrapper } from "../../../_components";
import useSettings from "../../../_hooks/useSettings";
import { CommonService } from "../../../_service";
import { getFieldRender } from "../../../_util";
import "./index.less";
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
var BaseInfo = function BaseInfo(props) {
  var _mapCenter, _info$geometryInfo3;
  var info = props.info,
    _props$data = props.data,
    data = _props$data === void 0 ? [] : _props$data,
    photos = props.photos,
    mapPoints = props.mapPoints,
    geometryType = props.geometryType,
    lineLayer = props.lineLayer,
    _props$customMapInfo = props.customMapInfo,
    customMapInfo = _props$customMapInfo === void 0 ? {} : _props$customMapInfo;
  var _useSettings = useSettings(),
    mapInfo = _useSettings.mapInfo;
  var fields = CommonService.useGetFields(info === null || info === void 0 ? void 0 : info.typeCode);
  var mapCenter = props.mapCenter || [];
  var _mapPoints = mapPoints;
  if (!(((_mapCenter = mapCenter) === null || _mapCenter === void 0 ? void 0 : _mapCenter.length) > 0)) {
    var _info$geometryInfo;
    if ((info === null || info === void 0 || (_info$geometryInfo = info.geometryInfo) === null || _info$geometryInfo === void 0 ? void 0 : _info$geometryInfo.type) === 'point') {
      var _info$geometryInfo2;
      mapCenter = (_info$geometryInfo2 = info.geometryInfo) === null || _info$geometryInfo2 === void 0 || (_info$geometryInfo2 = _info$geometryInfo2.lngLats) === null || _info$geometryInfo2 === void 0 ? void 0 : _info$geometryInfo2.split(',');
    }
  }
  if (!(mapPoints && (mapPoints === null || mapPoints === void 0 ? void 0 : mapPoints.length) > 0) && (info === null || info === void 0 || (_info$geometryInfo3 = info.geometryInfo) === null || _info$geometryInfo3 === void 0 ? void 0 : _info$geometryInfo3.type) === 'point') {
    var _info$geometryInfo4;
    _mapPoints = ((_info$geometryInfo4 = info.geometryInfo) === null || _info$geometryInfo4 === void 0 || (_info$geometryInfo4 = _info$geometryInfo4.lngLats) === null || _info$geometryInfo4 === void 0 || (_info$geometryInfo4 = _info$geometryInfo4.split(';')) === null || _info$geometryInfo4 === void 0 || (_info$geometryInfo4 = _info$geometryInfo4.map(function (item) {
      return item.split(',');
    })) === null || _info$geometryInfo4 === void 0 ? void 0 : _info$geometryInfo4.map(function (item, index) {
      return {
        id: "mapPoints_".concat(index),
        lng: item[0],
        lat: item[1],
        icon: info === null || info === void 0 ? void 0 : info.gisIconCode,
        color: info === null || info === void 0 ? void 0 : info.gisIconColor
      };
    })) || [];
  }
  return /*#__PURE__*/_jsxs("div", {
    className: "default-baseContent",
    children: [/*#__PURE__*/_jsx("div", {
      className: "default-baseContent-left",
      children: /*#__PURE__*/_jsxs(VmWrapper, {
        title: "\u57FA\u672C\u4FE1\u606F",
        children: [photos && /*#__PURE__*/_jsx("div", {
          className: "default-base-img",
          children: photos.length ? /*#__PURE__*/_jsx(VtxImage.PreviewGroup, {
            children: /*#__PURE__*/_jsx(Carousel, {
              style: {
                width: '100%',
                height: '100%',
                overflow: 'hidden'
              },
              children: photos.map(function (item) {
                return /*#__PURE__*/_jsx(VtxImage, {
                  src: "/cloudFile/common/downloadFile?id=".concat(item.id, "&token=").concat(getVtxToken('token')),
                  alt: item.name,
                  style: {
                    width: '100%',
                    height: '100%',
                    overflow: 'hidden'
                  }
                }, item.id);
              })
            })
          }) : /*#__PURE__*/_jsx(VmEmpty, {
            type: "NO_PICTURE",
            showText: false
          })
        }), /*#__PURE__*/_jsx("div", {
          className: "default-base-text",
          children: /*#__PURE__*/_jsx(VmInfoCollection, {
            data: (data === null || data === void 0 ? void 0 : data.length) > 0 ? data : getFieldRender(fields, info),
            horizontal: true,
            width: "50%",
            ellipsis: true
          })
        })]
      })
    }), /*#__PURE__*/_jsx("div", {
      className: "default-baseContent-right",
      children: /*#__PURE__*/_jsx("div", {
        className: "default-base-map",
        children: /*#__PURE__*/_jsx(VmMap, _objectSpread({
          mapCenter: mapCenter,
          mapType: (mapInfo === null || mapInfo === void 0 ? void 0 : mapInfo.mapType) || 'bmap',
          geometryType: geometryType,
          mapPoints: _mapPoints,
          mapPolygons: lineLayer !== null && lineLayer !== void 0 && lineLayer.rings ? [lineLayer] : []
        }, customMapInfo))
      })
    })]
  });
};
export default BaseInfo;