"use strict";

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.TreeItem2Icon = TreeItem2Icon;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var React = _interopRequireWildcard(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _resolveComponentProps = _interopRequireDefault(require("@mui/utils/resolveComponentProps"));
var _useSlotProps = _interopRequireDefault(require("@mui/utils/useSlotProps"));
var _TreeViewProvider = require("../internals/TreeViewProvider");
var _icons = require("../icons");
var _jsxRuntime = require("react/jsx-runtime");
function TreeItem2Icon(props) {
  const {
    slots,
    slotProps,
    status
  } = props;
  const context = (0, _TreeViewProvider.useTreeViewContext)();
  const contextIcons = (0, _extends2.default)({}, context.icons.slots, {
    expandIcon: context.icons.slots.expandIcon ?? _icons.TreeViewExpandIcon,
    collapseIcon: context.icons.slots.collapseIcon ?? _icons.TreeViewCollapseIcon
  });
  const contextIconProps = context.icons.slotProps;
  let iconName;
  if (slots?.icon) {
    iconName = 'icon';
  } else if (status.expandable) {
    if (status.expanded) {
      iconName = 'collapseIcon';
    } else {
      iconName = 'expandIcon';
    }
  } else {
    iconName = 'endIcon';
  }
  const Icon = slots?.[iconName] ?? contextIcons[iconName];
  const iconProps = (0, _useSlotProps.default)({
    elementType: Icon,
    externalSlotProps: tempOwnerState => (0, _extends2.default)({}, (0, _resolveComponentProps.default)(contextIconProps[iconName], tempOwnerState), (0, _resolveComponentProps.default)(slotProps?.[iconName], tempOwnerState)),
    // TODO: Add proper ownerState
    ownerState: {}
  });
  if (!Icon) {
    return null;
  }
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(Icon, (0, _extends2.default)({}, iconProps));
}
process.env.NODE_ENV !== "production" ? TreeItem2Icon.propTypes = {
  // ----------------------------- Warning --------------------------------
  // | These PropTypes are generated from the TypeScript type definitions |
  // | To update them edit the TypeScript types and run "pnpm proptypes"  |
  // ----------------------------------------------------------------------
  /**
   * The props used for each component slot.
   * @default {}
   */
  slotProps: _propTypes.default.object,
  /**
   * Overridable component slots.
   * @default {}
   */
  slots: _propTypes.default.object,
  status: _propTypes.default.shape({
    disabled: _propTypes.default.bool.isRequired,
    editable: _propTypes.default.bool.isRequired,
    editing: _propTypes.default.bool.isRequired,
    expandable: _propTypes.default.bool.isRequired,
    expanded: _propTypes.default.bool.isRequired,
    focused: _propTypes.default.bool.isRequired,
    selected: _propTypes.default.bool.isRequired
  }).isRequired
} : void 0;