"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
var _set2 = _interopRequireDefault(require("@babel/runtime/helpers/set"));
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _classPrivateFieldSet2 = _interopRequireDefault(require("@babel/runtime/helpers/classPrivateFieldSet"));
var _classPrivateFieldGet2 = _interopRequireDefault(require("@babel/runtime/helpers/classPrivateFieldGet"));
var THREE = _interopRequireWildcard(require("three"));
var _LayerUpdateState = _interopRequireDefault(require("./LayerUpdateState"));
var _ObjectRemovalHelper = _interopRequireDefault(require("../Process/ObjectRemovalHelper"));
var _GeometryLayer2 = _interopRequireDefault(require("./GeometryLayer"));
var _Coordinates = _interopRequireDefault(require("../Core/Geographic/Coordinates"));
var _Extent = _interopRequireDefault(require("../Core/Geographic/Extent"));
var _Label = _interopRequireDefault(require("../Core/Label"));
var _Feature = require("../Core/Feature");
var _Style = require("../Core/Style");
var _Label2DRenderer = require("../Renderer/Label2DRenderer");
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function () { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
var coord = new _Coordinates["default"]('EPSG:4326', 0, 0, 0);
var _extent = new _Extent["default"]('EPSG:4326', 0, 0, 0, 0);
var nodeDimensions = new THREE.Vector2();
var westNorthNode = new THREE.Vector2();
var labelPosition = new THREE.Vector2();

/**
 * DomNode is a node in the tree data structure of labels divs.
 *
 * @class DomNode
 */
var _domVisibility = /*#__PURE__*/new WeakMap();
var DomNode = /*#__PURE__*/function () {
  function DomNode() {
    (0, _classCallCheck2["default"])(this, DomNode);
    _classPrivateFieldInitSpec(this, _domVisibility, {
      writable: true,
      value: false
    });
    this.dom = document.createElement('div');
    this.dom.style.display = 'none';
    this.visible = true;
  }
  (0, _createClass2["default"])(DomNode, [{
    key: "visible",
    get: function get() {
      return (0, _classPrivateFieldGet2["default"])(this, _domVisibility);
    },
    set: function set(v) {
      if (v !== (0, _classPrivateFieldGet2["default"])(this, _domVisibility)) {
        (0, _classPrivateFieldSet2["default"])(this, _domVisibility, v);
        this.dom.style.display = v ? 'block' : 'none';
      }
    }
  }, {
    key: "hide",
    value: function hide() {
      this.visible = false;
    }
  }, {
    key: "show",
    value: function show() {
      this.visible = true;
    }
  }, {
    key: "add",
    value: function add(node) {
      this.dom.append(node.dom);
    }
  }]);
  return DomNode;
}();
/**
 * LabelsNode is node of tree data structure for LabelLayer.
 * the node is made of dom elements and 3D labels.
 *
 * @class      LabelsNode
 */
var LabelsNode = /*#__PURE__*/function (_THREE$Group) {
  (0, _inherits2["default"])(LabelsNode, _THREE$Group);
  var _super = _createSuper(LabelsNode);
  function LabelsNode(node) {
    var _this;
    (0, _classCallCheck2["default"])(this, LabelsNode);
    _this = _super.call(this);
    // attached node parent
    _this.nodeParent = node;
    // When this is set, it calculates the position in that frame and resets this property to false.
    _this.needsUpdate = true;
    return _this;
  }

  // instanciate dom elements
  (0, _createClass2["default"])(LabelsNode, [{
    key: "initializeDom",
    value: function initializeDom() {
      // create root dom
      this.domElements = new DomNode();
      // create labels container dom
      this.domElements.labels = new DomNode();
      this.domElements.add(this.domElements.labels);
      this.domElements.labels.dom.style.opacity = '0';
    }

    // add node label
    // add label 3d and dom label
  }, {
    key: "addLabel",
    value: function addLabel(label) {
      // add 3d object
      this.add(label);

      // add dom label
      this.domElements.labels.dom.append(label.content);

      // Batch update the dimensions of labels all at once to avoid
      // redraw for at least this tile.
      label.initDimensions();

      // add horizon culling point if it's necessary
      // the horizon culling is applied to nodes that trace the horizon which
      // corresponds to the low zoom node, that's why the culling is done for a zoom lower than 4.
      if (this.nodeParent.layer.isGlobeLayer && this.nodeParent.level < 4) {
        label.horizonCullingPoint = new THREE.Vector3();
      }
    }

    // remove node label
    // remove label 3d and dom label
  }, {
    key: "removeLabel",
    value: function removeLabel(label) {
      // remove 3d object
      this.remove(label);

      // remove dom label
      this.domElements.labels.dom.removeChild(label.content);
    }

    // update position if it's necessary
  }, {
    key: "updatePosition",
    value: function updatePosition(label) {
      if (this.needsUpdate) {
        // update elevation from elevation layer.
        if (this.needsAltitude) {
          label.updateElevationFromLayer(this.nodeParent.layer, [this.nodeParent]);
        }

        // update elevation label
        label.update3dPosition(this.nodeParent.layer.crs);

        // update horizon culling
        label.updateHorizonCullingPoint();
      }
    }

    // return labels count
  }, {
    key: "count",
    value: function count() {
      return this.children.length;
    }
  }, {
    key: "labels",
    get: function get() {
      return this.children;
    }
  }]);
  return LabelsNode;
}(THREE.Group);
/**
 * A layer to handle a bunch of `Label`. This layer can be created on its own,
 * but it is better to use the option `addLabelLayer` on another `Layer` to let
 * it work with it (see the `vector_tile_raster_2d` example).
 *
 * @property {boolean} isLabelLayer - Used to checkout whether this layer is a
 * LabelLayer.  Default is true. You should not change this, as it is used
 * internally for optimisation.
 */
var _filterGrid = /*#__PURE__*/new WeakMap();
var _submitToRendering = /*#__PURE__*/new WeakSet();
var _disallowToRendering = /*#__PURE__*/new WeakSet();
var _findClosestDomElement = /*#__PURE__*/new WeakSet();
var _hasLabelChildren = /*#__PURE__*/new WeakSet();
var _removeCulledLabels = /*#__PURE__*/new WeakSet();
var LabelLayer = /*#__PURE__*/function (_GeometryLayer) {
  (0, _inherits2["default"])(LabelLayer, _GeometryLayer);
  var _super2 = _createSuper(LabelLayer);
  /**
   * @constructor
   * @extends Layer
   *
   * @param {string} id - The id of the layer, that should be unique. It is
   * not mandatory, but an error will be emitted if this layer is added a
   * {@link View} that already has a layer going by that id.
   * @param {Object} [config] - Optional configuration, all elements in it
   * will be merged as is in the layer. For example, if the configuration
   * contains three elements `name, protocol, extent`, these elements will be
   * available using `layer.name` or something else depending on the property
   * name.
   * @param {boolean} [config.performance=true] - remove labels that have no chance of being visible.
   * if the `config.performance` is set to true then the performance is improved
   * proportional to the amount of unnecessary labels that are removed.
   * Indeed, even in the best case, labels will never be displayed. By example, if there's many labels.
   * We advise you to not use this option if your data is optimized.
   * @param {domElement|function} config.domElement - An HTML domElement.
   * If set, all `Label` displayed within the current instance `LabelLayer`
   * will be this domElement.
   *
   * It can be set to a method. The single parameter of this method gives the
   * properties of each feature on which a `Label` is created.
   *
   * If set, all the parameters set in the `LabelLayer` `Style.text` will be overridden,
   * except for the `Style.text.anchor` parameter which can help place the label.
   */
  function LabelLayer(id) {
    var _this2;
    var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
    (0, _classCallCheck2["default"])(this, LabelLayer);
    var domElement = config.domElement;
    delete config.domElement;
    _this2 = _super2.call(this, id, config.object3d || new THREE.Group(), config);
    // Remove all labels invisible with pre-culling with screen grid
    // We use the screen grid with maximum size of node on screen
    _classPrivateMethodInitSpec((0, _assertThisInitialized2["default"])(_this2), _removeCulledLabels);
    _classPrivateMethodInitSpec((0, _assertThisInitialized2["default"])(_this2), _hasLabelChildren);
    _classPrivateMethodInitSpec((0, _assertThisInitialized2["default"])(_this2), _findClosestDomElement);
    _classPrivateMethodInitSpec((0, _assertThisInitialized2["default"])(_this2), _disallowToRendering);
    _classPrivateMethodInitSpec((0, _assertThisInitialized2["default"])(_this2), _submitToRendering);
    _classPrivateFieldInitSpec((0, _assertThisInitialized2["default"])(_this2), _filterGrid, {
      writable: true,
      value: new _Label2DRenderer.ScreenGrid()
    });
    _this2.isLabelLayer = true;
    _this2.domElement = new DomNode();
    _this2.domElement.show();
    _this2.domElement.dom.id = "itowns-label-".concat(_this2.id);
    _this2.buildExtent = true;
    _this2.crs = config.source.crs;
    _this2.performance = config.performance || true;
    _this2.forceClampToTerrain = config.forceClampToTerrain || false;
    _this2.toHide = new THREE.Group();
    _this2.labelDomelement = domElement;

    // The margin property defines a space around each label that cannot be occupied by another label.
    // For example, if some labelLayer has a margin value of 5, there will be at least 10 pixels
    // between each labels of the layer
    // TODO : this property should be moved to Style after refactoring style properties structure
    _this2.margin = config.margin;
    return _this2;
  }
  (0, _createClass2["default"])(LabelLayer, [{
    key: "visible",
    get: function get() {
      return (0, _get2["default"])((0, _getPrototypeOf2["default"])(LabelLayer.prototype), "visible", this);
    },
    set: function set(value) {
      (0, _set2["default"])((0, _getPrototypeOf2["default"])(LabelLayer.prototype), "visible", value, this, true);
      if (value) {
        var _this$domElement;
        (_this$domElement = this.domElement) === null || _this$domElement === void 0 ? void 0 : _this$domElement.show();
      } else {
        var _this$domElement2;
        (_this$domElement2 = this.domElement) === null || _this$domElement2 === void 0 ? void 0 : _this$domElement2.hide();
      }
    }
  }, {
    key: "submittedLabelNodes",
    get: function get() {
      return this.object3d.children;
    }

    /**
     * Reads each {@link FeatureGeometry} that contains label configuration, and
     * creates the corresponding {@link Label}. To create a `Label`, a geometry
     * needs to have a `label` object with at least a few properties:
     * - `content`, which refers to `Label#content`
     * - `position`, which refers to `Label#position`
     * - (optional) `config`, containing miscellaneous configuration for the
     *   label
     *
     * The geometry (or its parent Feature) needs to have a Style set.
     *
     * @param {FeatureCollection} data - The FeatureCollection to read the
     * labels from.
     * @param {Extent} extent
     *
     * @return {Label[]} An array containing all the created labels.
     */
  }, {
    key: "convert",
    value: function convert(data, extent) {
      var _this3 = this;
      var labels = [];
      var layerField = this.style && this.style.text && this.style.text.field;

      // Converting the extent now is faster for further operation
      extent.as(data.crs, _extent);
      coord.crs = data.crs;
      var globals = {
        zoom: extent.zoom
      };
      data.features.forEach(function (f) {
        // TODO: add support for LINE and POLYGON
        if (f.type !== _Feature.FEATURE_TYPES.POINT) {
          return;
        }
        var featureField = f.style.text.field;

        // determine if altitude style is specified by the user
        var altitudeStyle = f.style.point.base_altitude;
        var isDefaultElevationStyle = altitudeStyle instanceof Function && altitudeStyle.name == 'base_altitudeDefault';

        // determine if the altitude needs update with ElevationLayer
        labels.needsAltitude = labels.needsAltitude || _this3.forceClampToTerrain === true || isDefaultElevationStyle && !f.hasRawElevationData;
        f.geometries.forEach(function (g) {
          // NOTE: this only works because only POINT is supported, it
          // needs more work for LINE and POLYGON
          coord.setFromArray(f.vertices, g.size * g.indices[0].offset);
          // Transform coordinate to data.crs projection
          coord.applyMatrix4(data.matrixWorld);
          if (!_extent.isPointInside(coord)) {
            return;
          }
          var geometryField = g.properties.style && g.properties.style.text.field;
          var content;
          var context = {
            globals: globals,
            properties: function properties() {
              return g.properties;
            }
          };
          if (_this3.labelDomelement) {
            content = (0, _Style.readExpression)(_this3.labelDomelement, context);
          } else if (!geometryField && !featureField && !layerField) {
            // Check if there is an icon, with no text
            if (!(g.properties.style && (g.properties.style.icon.source || g.properties.style.icon.key)) && !(f.style && (f.style.icon.source || f.style.icon.key)) && !(_this3.style && (_this3.style.icon.source || _this3.style.icon.key))) {
              return;
            }
          } else if (geometryField) {
            content = g.properties.style.getTextFromProperties(context);
          } else if (featureField) {
            content = f.style.getTextFromProperties(context);
          } else if (layerField) {
            content = _this3.style.getTextFromProperties(context);
          }
          var style = (g.properties.style || f.style || _this3.style).symbolStylefromContext(context);
          var label = new _Label["default"](content, coord.clone(), style, _this3.source.sprites);
          label.layerId = _this3.id;
          label.padding = _this3.margin || label.padding;
          labels.push(label);
        });
      });
      return labels;
    }

    // placeholder
  }, {
    key: "preUpdate",
    value: function preUpdate(context, sources) {
      if (sources.has(this.parent)) {
        this.object3d.clear();
        (0, _classPrivateFieldGet2["default"])(this, _filterGrid).width = this.parent.maxScreenSizeNode * 0.5;
        (0, _classPrivateFieldGet2["default"])(this, _filterGrid).height = this.parent.maxScreenSizeNode * 0.5;
        (0, _classPrivateFieldGet2["default"])(this, _filterGrid).resize();
      }
    }
  }, {
    key: "update",
    value: function update(context, layer, node, parent) {
      var _this4 = this;
      if (!parent && node.link[layer.id]) {
        // if node has been removed dispose three.js resource
        _ObjectRemovalHelper["default"].removeChildrenAndCleanupRecursively(this, node);
        return;
      }
      var labelsNode = node.link[layer.id] || new LabelsNode(node);
      node.link[layer.id] = labelsNode;
      if (this.frozen || !node.visible || !this.visible) {
        return;
      }
      if (!node.material.visible && _classPrivateMethodGet(this, _hasLabelChildren, _hasLabelChildren2).call(this, node)) {
        return _classPrivateMethodGet(this, _disallowToRendering, _disallowToRendering2).call(this, labelsNode);
      }
      var extentsDestination = node.getExtentsByProjection(this.source.crs) || [node.extent];
      var zoomDest = extentsDestination[0].zoom;
      if (zoomDest < layer.zoom.min || zoomDest > layer.zoom.max) {
        return _classPrivateMethodGet(this, _disallowToRendering, _disallowToRendering2).call(this, labelsNode);
      }
      if (node.layerUpdateState[this.id] === undefined) {
        node.layerUpdateState[this.id] = new _LayerUpdateState["default"]();
      }
      if (!this.source.extentInsideLimit(node.extent, zoomDest)) {
        node.layerUpdateState[this.id].noMoreUpdatePossible();
        return;
      } else if (_classPrivateMethodGet(this, _hasLabelChildren, _hasLabelChildren2).call(this, node.parent)) {
        if (!node.material.visible) {
          labelsNode.needsUpdate = true;
        }
        _classPrivateMethodGet(this, _submitToRendering, _submitToRendering2).call(this, labelsNode);
        return;
      } else if (!node.layerUpdateState[this.id].canTryUpdate()) {
        return;
      }
      node.layerUpdateState[this.id].newTry();
      var command = {
        layer: this,
        extentsSource: extentsDestination,
        view: context.view,
        requester: node
      };
      return context.scheduler.execute(command).then(function (result) {
        if (!result) {
          return;
        }
        var renderer = context.view.mainLoop.gfxEngine.label2dRenderer;
        labelsNode.initializeDom();
        _classPrivateMethodGet(_this4, _findClosestDomElement, _findClosestDomElement2).call(_this4, node).add(labelsNode.domElements);
        result.forEach(function (labels) {
          // Clean if there isnt' parent
          if (!node.parent) {
            labels.forEach(function (l) {
              _ObjectRemovalHelper["default"].removeChildrenAndCleanupRecursively(_this4, l);
              renderer.removeLabelDOM(l);
            });
            return;
          }
          labelsNode.needsAltitude = labelsNode.needsAltitude || labels.needsAltitude;

          // Add all labels for this tile at once to batch it
          labels.forEach(function (label) {
            if (node.extent.isPointInside(label.coordinates)) {
              labelsNode.addLabel(label);
            }
          });
        });
        if (labelsNode.count()) {
          labelsNode.domElements.labels.hide();
          labelsNode.domElements.labels.dom.style.opacity = '1.0';
          node.addEventListener('show', function () {
            return labelsNode.domElements.labels.show();
          });
          node.addEventListener('hidden', function () {
            return _classPrivateMethodGet(_this4, _disallowToRendering, _disallowToRendering2).call(_this4, labelsNode);
          });

          // Necessary event listener, to remove any Label attached to
          node.addEventListener('removed', function () {
            return _this4.removeNodeDomElement(node);
          });
          if (labelsNode.needsAltitude && node.material.getElevationLayer()) {
            node.material.getElevationLayer().addEventListener('rasterElevationLevelChanged', function () {
              labelsNode.needsUpdate = true;
            });
          }
          if (_this4.performance) {
            _classPrivateMethodGet(_this4, _removeCulledLabels, _removeCulledLabels2).call(_this4, labelsNode);
          }
        }
        node.layerUpdateState[_this4.id].noMoreUpdatePossible();
      });
    }
  }, {
    key: "removeLabelsFromNodeRecursive",
    value: function removeLabelsFromNodeRecursive(node) {
      var _this5 = this;
      node.children.forEach(function (c) {
        if (c.link[_this5.id]) {
          delete c.link[_this5.id];
        }
        _this5.removeLabelsFromNodeRecursive(c);
      });
      this.removeNodeDomElement(node);
    }
  }, {
    key: "removeNodeDomElement",
    value: function removeNodeDomElement(node) {
      var _node$link$this$id;
      if ((_node$link$this$id = node.link[this.id]) !== null && _node$link$this$id !== void 0 && _node$link$this$id.domElements) {
        var child = node.link[this.id].domElements.dom;
        child.parentElement.removeChild(child);
        delete node.link[this.id].domElements;
      }
    }

    /**
     * All layer's objects and domElements are removed.
     * @param {boolean} [clearCache=false] Whether to clear the layer cache or not
     */
  }, {
    key: "delete",
    value: function _delete(clearCache) {
      var _this6 = this;
      if (clearCache) {
        this.cache.clear();
      }
      this.domElement.dom.parentElement.removeChild(this.domElement.dom);
      this.parent.level0Nodes.forEach(function (obj) {
        return _this6.removeLabelsFromNodeRecursive(obj);
      });
    }
  }]);
  return LabelLayer;
}(_GeometryLayer2["default"]);
function _submitToRendering2(labelsNode) {
  this.object3d.add(labelsNode);
}
function _disallowToRendering2(labelsNode) {
  this.toHide.add(labelsNode);
}
function _findClosestDomElement2(node) {
  var _node$parent;
  if ((_node$parent = node.parent) !== null && _node$parent !== void 0 && _node$parent.isTileMesh) {
    var _node$parent$link$thi;
    return ((_node$parent$link$thi = node.parent.link[this.id]) === null || _node$parent$link$thi === void 0 ? void 0 : _node$parent$link$thi.domElements) || _classPrivateMethodGet(this, _findClosestDomElement, _findClosestDomElement2).call(this, node.parent);
  } else {
    return this.domElement;
  }
}
function _hasLabelChildren2(object) {
  var _this7 = this;
  return object.children.every(function (c) {
    var _c$layerUpdateState$_;
    return c.layerUpdateState && ((_c$layerUpdateState$_ = c.layerUpdateState[_this7.id]) === null || _c$layerUpdateState$_ === void 0 ? void 0 : _c$layerUpdateState$_.hasFinished());
  });
}
function _removeCulledLabels2(node) {
  var _this8 = this;
  // copy labels array
  var labels = node.children.slice();

  // reset filter
  (0, _classPrivateFieldGet2["default"])(this, _filterGrid).reset();

  // sort labels by order
  labels.sort(function (a, b) {
    return b.order - a.order;
  });
  labels.forEach(function (label) {
    // get node dimensions
    node.nodeParent.extent.planarDimensions(nodeDimensions);
    coord.crs = node.nodeParent.extent.crs;

    // get west/north node coordinates
    coord.setFromValues(node.nodeParent.extent.west, node.nodeParent.extent.north, 0).toVector3(westNorthNode);

    // get label position
    coord.copy(label.coordinates).as(node.nodeParent.extent.crs, coord).toVector3(labelPosition);

    // transform label position to local node system
    labelPosition.sub(westNorthNode);
    labelPosition.y += nodeDimensions.y;
    labelPosition.divide(nodeDimensions).multiplyScalar((0, _classPrivateFieldGet2["default"])(_this8, _filterGrid).width);

    // update the projected position to transform to local filter grid sytem
    label.updateProjectedPosition(labelPosition.x, labelPosition.y);

    // use screen grid to remove all culled labels
    if (!(0, _classPrivateFieldGet2["default"])(_this8, _filterGrid).insert(label)) {
      node.removeLabel(label);
    }
  });
}
var _default = LabelLayer;
exports["default"] = _default;