function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }

function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }

/*
Copyright (c) 2018-2020 Uber Technologies, Inc.

This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
*/
import React from 'react';
import { StyledIconContainer, StyledItemContent } from './styled-components.js';
import CheckIndeterminateIcon from '../icon/check-indeterminate.js';
import PlusIcon from '../icon/plus.js';
import { getOverride, getOverrideProps } from '../helpers/overrides.js';

var TreeLabel = function TreeLabel(_ref) {
  var hasChildren = _ref.hasChildren,
      isExpanded = _ref.isExpanded,
      label = _ref.label,
      _ref$overrides = _ref.overrides,
      overrides = _ref$overrides === void 0 ? {} : _ref$overrides,
      node = _ref.node,
      props = _objectWithoutProperties(_ref, ["hasChildren", "isExpanded", "label", "overrides", "node"]);

  var IconContainerOverride = overrides.IconContainer,
      ExapandIconOverride = overrides.ExpandIcon,
      CollapseIconOverride = overrides.CollapseIcon,
      TreeItemContentOverride = overrides.TreeItemContent;
  var IconContainer = getOverride(IconContainerOverride) || StyledIconContainer;
  var ExpandIcon = getOverride(ExapandIconOverride) || PlusIcon;
  var CollapseIcon = getOverride(CollapseIconOverride) || CheckIndeterminateIcon;
  var TreeItemContent = getOverride(TreeItemContentOverride) || StyledItemContent;
  return React.createElement(TreeItemContent, props, hasChildren && React.createElement(IconContainer, getOverrideProps(IconContainerOverride), !isExpanded ? React.createElement(ExpandIcon, getOverrideProps(ExapandIconOverride)) : React.createElement(CollapseIcon, getOverrideProps(CollapseIconOverride))), typeof label === 'function' ? label(node) : label);
};

export default TreeLabel;