"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = exports.ICON_SIDEBAR_POSITION = void 0;
var _react = _interopRequireDefault(require("react"));
var _classnames = _interopRequireDefault(require("classnames"));
var _faEllipsisVertical = require("@fortawesome/free-solid-svg-icons/faEllipsisVertical");
var _dropdownMenu = require("../dropdown-menu");
var _adaptiveList = require("../adaptive-list");
var _useTranslation = require("../hooks/use-translation");
var _withIconSidebarItem = require("./with-icon-sidebar-item");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
let ICON_SIDEBAR_POSITION = exports.ICON_SIDEBAR_POSITION = /*#__PURE__*/function (ICON_SIDEBAR_POSITION) {
  ICON_SIDEBAR_POSITION["LEFT"] = "left";
  ICON_SIDEBAR_POSITION["RIGHT"] = "right";
  return ICON_SIDEBAR_POSITION;
}({});
/**
 * @midnight-gray-supported
 * @uxr-only-supported
 * @alpine-light-supported
 */
function IconSidebar({
  className,
  options,
  selected,
  onSelect,
  footerOption,
  position = ICON_SIDEBAR_POSITION.LEFT,
  moreButtonText,
  LinkComponent
}) {
  const {
    t
  } = (0, _useTranslation.useTranslation)();
  const ItemComponent = (0, _withIconSidebarItem.withIconSidebarItem)(LinkComponent);
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
    className: (0, _classnames.default)('icon-sidebar-container', className, position),
    children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
      className: "icon-sidebar-main-container",
      children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_adaptiveList.AdaptiveList, {
        selected: selected,
        onSelect: onSelect,
        Component: ItemComponent,
        target: "offsetHeight",
        triggerOffset: 62,
        options: options,
        dropdownMenuProps: {
          triggerIsIcon: false,
          placement: position === ICON_SIDEBAR_POSITION.LEFT ? _dropdownMenu.DROPDOWN_MENU_PLACEMENT_TYPES.RIGHT_START : _dropdownMenu.DROPDOWN_MENU_PLACEMENT_TYPES.LEFT_START,
          triggerDynamicContent: ({
            isOpen
          }) => /*#__PURE__*/(0, _jsxRuntime.jsx)(ItemComponent, {
            option: {
              key: 'more-trigger',
              title: moreButtonText ?? t('More'),
              icon: _faEllipsisVertical.faEllipsisVertical
            },
            selected: isOpen ? 'more-trigger' : undefined
          })
        }
      })
    }), footerOption && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
      className: "icon-sidebar-footer-container",
      children: /*#__PURE__*/(0, _jsxRuntime.jsx)(ItemComponent, {
        option: footerOption,
        onSelect: onSelect,
        selected: selected
      })
    })]
  });
}
var _default = exports.default = IconSidebar;