"use strict";

var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _filter = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/filter"));
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/createClass"));
var ROW_DRAG_STATUS = 'rowDragStatus';
var RowDragApi = exports.default = /*#__PURE__*/function () {
  function RowDragApi(pipeline) {
    (0, _classCallCheck2.default)(this, RowDragApi);
    this.pipeline = pipeline;
    this.rowDropZoneParams = null;
    this.rowDropZones = [];
    this.dragStatus = 'finished';
  }
  return (0, _createClass2.default)(RowDragApi, [{
    key: "getRowDropZoneParams",
    value: function getRowDropZoneParams() {
      return this.rowDropZoneParams;
    }
  }, {
    key: "setRowDropZoneParams",
    value: function setRowDropZoneParams(params) {
      this.rowDropZoneParams = params;
    }
  }, {
    key: "addRowDropZone",
    value: function addRowDropZone(rowDropZone) {
      if (!rowDropZone || !(rowDropZone === null || rowDropZone === void 0 ? void 0 : rowDropZone.getContainer())) {
        return;
      }
      var isExist = this.rowDropZones.some(function (zone) {
        return zone.getContainer() === rowDropZone.getContainer();
      });
      if (isExist) {
        return;
      }
      this.rowDropZones.push(rowDropZone);
    }
  }, {
    key: "getRowDropZone",
    value: function getRowDropZone() {
      return this.rowDropZones;
    }
  }, {
    key: "removeRowDropZone",
    value: function removeRowDropZone(rowDropZone) {
      var _context;
      this.rowDropZones = (0, _filter.default)(_context = this.rowDropZones).call(_context, function (zone) {
        return zone.getContainer() !== rowDropZone.getContainer();
      });
    }
  }, {
    key: "setDragStatus",
    value: function setDragStatus(status) {
      var currentStatus = this.dragStatus;
      this.dragStatus = status;
      if (currentStatus !== status) {
        this.pipeline.setStateAtKey(ROW_DRAG_STATUS, status);
      }
    }
  }, {
    key: "getDragStatus",
    value: function getDragStatus() {
      return this.dragStatus;
    }
  }]);
}();