"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;
var _react = _interopRequireDefault(require("react"));
var _components = require("@vtx/components");
var _antd = require("antd");
var _util = require("../../../util");
var _useSettings2 = _interopRequireDefault(require("../../../vm-hooks/useSettings"));
var _vmNodata = _interopRequireDefault(require("../../../vm-nodata"));
var _vmMap = _interopRequireDefault(require("../../../vm-map"));
var _api = require("../../api");
var _vmInfoCollection = _interopRequireDefault(require("../../../vm-info-collection"));
require("./index.less");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
var BaseInfo = function BaseInfo(props) {
  var _a, _b, _c, _d, _e, _f, _g, _h;
  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 = (0, _useSettings2["default"])(),
    theme = _useSettings.theme,
    mapInfo = _useSettings.mapInfo;
  var fields = _api.BaseService.getFields(info === null || info === void 0 ? void 0 : info.typeCode);
  var mapCenter = props.mapCenter || [];
  var _mapPoints = mapPoints;
  if (!((mapCenter === null || mapCenter === void 0 ? void 0 : mapCenter.length) > 0)) {
    if (((_a = info === null || info === void 0 ? void 0 : info.geometryInfo) === null || _a === void 0 ? void 0 : _a.type) == 'point') {
      mapCenter = (_c = (_b = info.geometryInfo) === null || _b === void 0 ? void 0 : _b.lngLats) === null || _c === void 0 ? void 0 : _c.split(',');
    }
  }
  if (!(mapPoints && (mapPoints === null || mapPoints === void 0 ? void 0 : mapPoints.length) > 0) && ((_d = info === null || info === void 0 ? void 0 : info.geometryInfo) === null || _d === void 0 ? void 0 : _d.type) == 'point') {
    _mapPoints = ((_h = (_g = (_f = (_e = info.geometryInfo) === null || _e === void 0 ? void 0 : _e.lngLats) === null || _f === void 0 ? void 0 : _f.split(';')) === null || _g === void 0 ? void 0 : _g.map(function (item) {
      return item.split(',');
    })) === null || _h === void 0 ? void 0 : _h.map(function (item, index) {
      return {
        id: "mapPoints_".concat(index),
        lng: item[0],
        lat: item[1]
      };
    })) || [];
  }
  return /*#__PURE__*/_react["default"].createElement("div", {
    className: "default-baseContent ".concat(theme)
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "default-base"
  }, photos && (/*#__PURE__*/_react["default"].createElement("div", {
    className: "default-base-img"
  }, photos.length ? (/*#__PURE__*/_react["default"].createElement(_components.VtxImage.PreviewGroup, null, /*#__PURE__*/_react["default"].createElement(_antd.Carousel, {
    style: {
      width: '370px',
      height: '244px',
      overflow: 'hidden'
    }
  }, photos.map(function (item) {
    return /*#__PURE__*/_react["default"].createElement(_components.VtxImage, {
      key: item.id,
      src: "/cloudFile/common/downloadFile?id=".concat(item.id, "&token=").concat((0, _util.getUrlPara)('token')),
      alt: item.name,
      isDark: true,
      style: {
        maxHeight: '244px',
        overflow: 'hidden'
      }
    });
  })))) : (/*#__PURE__*/_react["default"].createElement(_vmNodata["default"], null)))), /*#__PURE__*/_react["default"].createElement("div", {
    className: "default-base-text"
  }, /*#__PURE__*/_react["default"].createElement(_vmInfoCollection["default"], {
    data: (data === null || data === void 0 ? void 0 : data.length) > 0 ? data : (0, _util.getFieldRender)(fields, info),
    horizontal: true,
    width: "50%",
    ellipsis: true
  }))), /*#__PURE__*/_react["default"].createElement("div", {
    className: "default-base-map"
  }, /*#__PURE__*/_react["default"].createElement(_vmMap["default"], Object.assign({
    mapCenter: mapCenter,
    mapType: (mapInfo === null || mapInfo === void 0 ? void 0 : mapInfo.mapType) || 'bmap',
    geometryType: geometryType,
    mapPoints: _mapPoints,
    mapPolygons: (lineLayer === null || lineLayer === void 0 ? void 0 : lineLayer.rings) ? [lineLayer] : []
  }, customMapInfo))));
};
var _default = exports["default"] = BaseInfo;
//# sourceMappingURL=index.js.map
