import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import { Column, ItemType } from './Column';
export var ColumnTreeView =
/*#__PURE__*/
function (_Component) {
  _inheritsLoose(ColumnTreeView, _Component);

  function ColumnTreeView() {
    var _this;

    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }

    _this = _Component.call.apply(_Component, [this].concat(args)) || this;

    _defineProperty(_assertThisInitialized(_this), "renderColumn", function (_ref, index) {
      var parentId = _ref.parentId,
          isActive = _ref.isActive,
          selectedId = _ref.selectedId,
          items = _ref.items;
      var _this$props = _this.props,
          onSelect = _this$props.onSelect,
          countChildren = _this$props.countChildren;
      return React.createElement(Column, {
        key: parentId,
        isActive: isActive,
        selectedId: selectedId,
        items: items,
        onSelect: onSelect,
        countChildren: countChildren,
        index: index
      });
    });

    _defineProperty(_assertThisInitialized(_this), "renderChildren", function () {
      var children = _this.props.children;
      var wrappedChildren = null;

      if (children) {
        wrappedChildren = React.createElement("div", {
          className: "rc-column-tree-view-content"
        }, children);
      }

      return wrappedChildren;
    });

    return _this;
  }

  var _proto = ColumnTreeView.prototype;

  _proto.render = function render() {
    var _this$props2 = this.props,
        columns = _this$props2.columns,
        testAutomationId = _this$props2.testAutomationId,
        fixedHeight = _this$props2.fixedHeight;
    var classNames = classnames('rc-column-tree-view', {
      'rc-column-tree-view-fixed-height': fixedHeight
    });
    return React.createElement("div", {
      className: classNames,
      "data-test-automation-id": testAutomationId
    }, columns.map(this.renderColumn), this.renderChildren());
  };

  return ColumnTreeView;
}(Component);

_defineProperty(ColumnTreeView, "propTypes", {
  children: PropTypes.node,
  columns: PropTypes.arrayOf(PropTypes.shape({
    parentId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
    isActive: PropTypes.bool,
    selectedId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
    items: PropTypes.arrayOf(ItemType)
  })),
  onSelect: PropTypes.func,
  countChildren: PropTypes.func,
  testAutomationId: PropTypes.string,
  fixedHeight: PropTypes.bool
});

_defineProperty(ColumnTreeView, "defaultProps", {
  children: null,
  columns: [],
  onSelect: function onSelect(id) {},
  countChildren: function countChildren(id) {
    return 0;
  },
  testAutomationId: 'columnTreeView',
  fixedHeight: false
});