"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;
var _propTypes = _interopRequireDefault(require("prop-types"));
var _react = _interopRequireDefault(require("react"));
var _Status = _interopRequireDefault(require("./Status"));
var _useGetFacility2 = _interopRequireDefault(require("../_mapUtil/useGetFacility"));
var _GwLayer = _interopRequireDefault(require("../_component/GwLayer"));
var _config = require("./config");
var _olMap = require("@vtx/ol-map");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
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); }
// eslint-disable-next-line react/prop-types
var Popup = function Popup(_ref) {
  var _data$dataJson, _info$dataJson, _info$dataJson2;
  var _ref$info = _ref.info,
    info = _ref$info === void 0 ? {} : _ref$info,
    openModal = _ref.openModal;
  var _useGetFacility = (0, _useGetFacility2["default"])(info.id),
    _useGetFacility$data = _useGetFacility.data,
    data = _useGetFacility$data === void 0 ? {} : _useGetFacility$data;
  var list = [{
    content: /*#__PURE__*/_react["default"].createElement(_Status["default"], {
      info: info
    }),
    span: 24
  }, {
    label: '所在道路',
    value: info.roadName || '-'
  }, {
    label: '管材',
    value: (data === null || data === void 0 || (_data$dataJson = data.dataJson) === null || _data$dataJson === void 0 ? void 0 : _data$dataJson.lineTextureName) || '-'
  }, {
    label: '管长',
    value: (info === null || info === void 0 || (_info$dataJson = info.dataJson) === null || _info$dataJson === void 0 ? void 0 : _info$dataJson.lineLength) + 'm'
  }, {
    label: '管径',
    value: (info === null || info === void 0 || (_info$dataJson2 = info.dataJson) === null || _info$dataJson2 === void 0 ? void 0 : _info$dataJson2.ds) + 'mm'
  }, {
    label: [_config.SedimentationType.ZC, _config.SedimentationType.GTGD].includes(info.sedimentationType) ? '平均液位' : '淤积时段平均液位',
    value: "".concat(info.avgWaterLevel || '-', "m")
  }, {
    label: [_config.SedimentationType.ZC, _config.SedimentationType.GTGD].includes(info.sedimentationType) ? '平均流速' : '淤积时段平均流速',
    value: "".concat(info.avgFlowSpeed || '-', "m/s")
  }];
  return /*#__PURE__*/_react["default"].createElement(_olMap.Popup.Template, {
    contentList: list,
    column: 2,
    contentStyle: {
      width: 390
    },
    detail: {
      show: true,
      onClick: function onClick() {
        var _info$facility;
        return openModal({
          facilityId: info === null || info === void 0 || (_info$facility = info.facility) === null || _info$facility === void 0 ? void 0 : _info$facility.id
        });
      }
    }
  });
};
var MapLayer = function MapLayer(_ref2) {
  var data = _ref2.data,
    openModal = _ref2.openModal;
  var group = [_config.SedimentationType.ZC, _config.SedimentationType.TFDS, _config.SedimentationType.CQYJ, _config.SedimentationType.GTGD].map(function (key) {
    return {
      name: _config.SedimentationTypeName[key],
      key: "SEDIMENTATION_GW_".concat(key),
      color: _config.SedimentationTypeColor[key],
      filter: function filter(f) {
        return f.sedimentationType === key;
      }
    };
  });
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_GwLayer["default"], {
    lineData: data.map(function (item) {
      return _objectSpread(_objectSpread({}, item), (item === null || item === void 0 ? void 0 : item.facility) || {});
    }),
    pointData: data.map(function (item) {
      var _item$facility, _item$facility2;
      return _objectSpread(_objectSpread(_objectSpread({}, item), (item === null || item === void 0 ? void 0 : item.facility) || {}), {}, {
        geometryInfo: _objectSpread(_objectSpread({}, (item === null || item === void 0 || (_item$facility = item.facility) === null || _item$facility === void 0 ? void 0 : _item$facility.geometryInfo) || {}), {}, {
          lngLats: item === null || item === void 0 || (_item$facility2 = item.facility) === null || _item$facility2 === void 0 || (_item$facility2 = _item$facility2.geometryInfo) === null || _item$facility2 === void 0 || (_item$facility2 = _item$facility2.lngLats) === null || _item$facility2 === void 0 || (_item$facility2 = _item$facility2.split(';')) === null || _item$facility2 === void 0 ? void 0 : _item$facility2[0],
          type: 'point'
        })
      });
    }),
    group: group,
    id: 'SEDIMENTATION_GW',
    template: function template(feature) {
      return /*#__PURE__*/_react["default"].createElement(Popup, {
        info: feature.values_,
        openModal: openModal
      });
    }
  }));
};
MapLayer.propTypes = {
  data: _propTypes["default"].array,
  openModal: _propTypes["default"].func
};
var _default = exports["default"] = MapLayer;
//# sourceMappingURL=MapLayer.js.map
