"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

exports.__esModule = true;
exports.TreeList = void 0;

var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));

var _List2 = require("./withStore/List");

var TreeList =
/*#__PURE__*/
function (_List) {
  (0, _inheritsLoose2.default)(TreeList, _List);

  function TreeList(props, context) {
    var _this;

    _this = _List.call(this, props, context) || this;
    _this.state = {
      nodes: _this.props.store.getData()
    };
    return _this;
  }

  var _proto = TreeList.prototype;

  _proto.onStoreChange = function onStoreChange(data) {
    this.setState({
      nodes: data
    });
  };

  _proto.hasItems = function hasItems() {
    return this.props.store.getFilteredCount() > 0;
  };

  _proto.isEmptyList = function isEmptyList() {
    return this.props.store.isLoaded() && !this.props.store.hasFilters() && !this.props.store.getTotalCount();
  };

  _proto.isEmptyListMessageVisible = function isEmptyListMessageVisible() {
    return this.props.store.isLoaded() && !this.hasItems();
  };

  _proto.renderItems = function renderItems() {
    var _this2 = this;

    var result = [];
    this.state.nodes.forEach(function (node, index) {
      _this2.props.store.applyCallbackToSubtree(node, index, function (record, recordIndex, level) {
        result.push(_this2.renderItem(record, recordIndex, level));
      });
    });
    return result;
  };

  _proto.renderItem = function renderItem(record, index, level) {
    return null;
  };

  return TreeList;
}(_List2.List);

exports.TreeList = TreeList;