"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;

var _react = _interopRequireDefault(require("react"));

var _deck = require("deck.gl");

var _shortid = _interopRequireDefault(require("shortid"));

var _propTypes = require("prop-types");

var _mapStyles = _interopRequireDefault(require("./mapStyles"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

var MultiScreenGridMap = function MultiScreenGridMap(props) {
  var id = props.id,
      data = props.data,
      _props$pickable = props.pickable,
      pickable = _props$pickable === void 0 ? true : _props$pickable,
      _props$civicColor = props.civicColor,
      civicColor = _props$civicColor === void 0 ? "thermal" : _props$civicColor,
      _props$opacity = props.opacity,
      opacity = _props$opacity === void 0 ? 0.7 : _props$opacity,
      _props$getPosition = props.getPosition,
      getPosition = _props$getPosition === void 0 ? function (f) {
    return f.geometry.coordinates;
  } : _props$getPosition,
      _props$squareSize = props.squareSize,
      squareSize = _props$squareSize === void 0 ? 10 : _props$squareSize,
      _props$autoHighlight = props.autoHighlight,
      autoHighlight = _props$autoHighlight === void 0 ? true : _props$autoHighlight,
      _props$highlightColor = props.highlightColor,
      highlightColor = _props$highlightColor === void 0 ? [255, 255, 0, 100] : _props$highlightColor,
      _props$fieldName = props.fieldName,
      fieldName = _props$fieldName === void 0 ? {} : _props$fieldName;
  var colorRange = _mapStyles["default"][civicColor];

  var getWeight = function getWeight(feature) {
    var fieldNameWeight = fieldName.weight;

    if (fieldName && fieldNameWeight) {
      var weight = feature.properties[fieldNameWeight];
      return weight || 1;
    }

    return 1;
  };

  return _react["default"].createElement(_deck.ScreenGridLayer, {
    key: _shortid["default"].generate(),
    id: id,
    pickable: pickable,
    data: data,
    getPosition: getPosition,
    opacity: opacity,
    colorRange: colorRange,
    cellSizePixels: squareSize,
    autoHighlight: autoHighlight,
    highlightColor: highlightColor,
    gpuAggregation: false,
    updateTriggers: {
      colorRange: colorRange
    },
    getWeight: getWeight
  });
};

MultiScreenGridMap.propTypes = {
  id: _propTypes.string.isRequired,
  data: (0, _propTypes.arrayOf)((0, _propTypes.shape)({})).isRequired,
  pickable: _propTypes.bool,
  civicColor: _propTypes.string,
  opacity: _propTypes.number,
  getPosition: _propTypes.func,
  squareSize: _propTypes.number,
  autoHighlight: _propTypes.bool,
  highlightColor: (0, _propTypes.arrayOf)(_propTypes.number),
  fieldName: (0, _propTypes.shape)({
    weight: _propTypes.string
  })
};
var _default = MultiScreenGridMap;
exports["default"] = _default;