"use strict";

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

exports.__esModule = true;
exports["default"] = void 0;

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

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

var _styledComponents = _interopRequireDefault(require("styled-components"));

var _Tree = _interopRequireDefault(require("./components/Tree"));

var _TreeNode = _interopRequireDefault(require("./components/TreeNode"));

var _templateObject;

var StyledNode = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteralLoose2["default"])(["\n  background: rgba(30, 84, 105, 0.3);\n  width:240px;\n  border-radius: 8px;\n  display: inline-block;\n  border: 1px solid #415263;\n  .main-head{\n    background: rgba(26, 54, 87, 0.5);\n    height: 32px;\n    line-height:32px;\n    display:flex;\n    padding:5px 16px;\n    color: #FFFFFF;\n    border-radius: 8px 8px 0 0;\n    border-bottom: 1px solid #415263;\n    justify-content: space-between;\n    .head-l{\n    }\n    .head-r{\n      font-weight:700;\n    }\n  }\n  .main-body{\n    background: rgba(30, 84, 105, 0.3);\n    color: rgba(255, 255, 255, 0.8);\n    text-align:left;\n    padding:10px 16px;\n    .body-bottom{\n      margin-bottom:8px;\n    }\n    .body-type{\n      display:inline-block;\n      color: #F76965;\n      padding:0 3px;\n      border-radious:2px;\n      border:1px solid #F76965;\n    }\n  }\n"])));

//单个组件
function MainContent(props) {
  var info = props.info;
  return /*#__PURE__*/_react["default"].createElement(StyledNode, null, /*#__PURE__*/_react["default"].createElement("div", {
    className: "main-head"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "head-l"
  }, info.position), /*#__PURE__*/_react["default"].createElement("div", {
    className: "head-r"
  }, info.name)), /*#__PURE__*/_react["default"].createElement("div", {
    className: "main-body"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "body-bottom"
  }, info.sex), /*#__PURE__*/_react["default"].createElement("div", {
    className: "body-bottom"
  }, info.phone)));
}

function enhanceContent(list) {
  if (list === void 0) {
    list = [];
  }

  var divList = [];
  list.forEach(function (el) {
    if (el !== null && el !== void 0 && el.children) {
      divList.push( /*#__PURE__*/_react["default"].createElement(_TreeNode["default"], {
        key: el,
        label: /*#__PURE__*/_react["default"].createElement(MainContent, {
          info: el
        }, "  ")
      }, enhanceContent(el.children)));
    } else {
      divList.push( /*#__PURE__*/_react["default"].createElement(_TreeNode["default"], {
        key: el,
        label: /*#__PURE__*/_react["default"].createElement(MainContent, {
          info: el
        }, "  ")
      }));
    }
  });
  return divList;
}

var reactTree = function reactTree(_ref) {
  var _ref$bodyData = _ref.bodyData,
      bodyData = _ref$bodyData === void 0 ? [{
    position: '经理',
    name: '顾念',
    sex: '男',
    phone: '18300735684'
  }] : _ref$bodyData,
      _ref$rootData = _ref.rootData,
      rootData = _ref$rootData === void 0 ? {
    position: '董事长',
    name: '李嘉图',
    sex: '男',
    phone: '18300735684'
  } : _ref$rootData;
  return /*#__PURE__*/_react["default"].createElement(_Tree["default"], {
    lineWidth: '2px',
    lineColor: '#59646a',
    lineBorderRadius: '10px',
    label: /*#__PURE__*/_react["default"].createElement(MainContent, {
      info: rootData
    }, "  ")
  }, bodyData.length ? enhanceContent(bodyData) : null);
};

var _default = reactTree;
exports["default"] = _default;