"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var Item_exports = {};
__export(Item_exports, {
  ItemLabel: () => ItemLabel,
  default: () => Item_default
});
module.exports = __toCommonJS(Item_exports);
var import_react = __toESM(require("react"));
var import_styled_components = __toESM(require("styled-components"));
var import__ = __toESM(require("../index"));
var import_Text = __toESM(require("../../../asorted/Text"));
var import_TransitionInOut = __toESM(require("../../../transitions/TransitionInOut"));
var import_Flex = __toESM(require("../../../layout/Flex"));
const ItemWrapper = import_styled_components.default.li`
  /** DEFAULT VARIANT **/
  --ll-sidebar-item-label-color: ${(props) => props.theme.colors.neutral.c80};
  --ll-sidebar-item-icon-color: ${(props) => props.theme.colors.neutral.c80};
  --ll-sidebar-item-background-color: unset;

  display: flex;
  flex-direction: row;
  align-items: center;
  margin-top: ${(p) => p.theme.space[3]}px;
  column-gap: ${(p) => p.theme.space[5]}px;
  padding: ${(p) => p.theme.space[5]}px;
  border-radius: ${(p) => p.theme.space[3]}px;
  min-height: ${(p) => p.theme.space[13]}px;
  min-width: ${(p) => p.theme.space[13]}px;

  color: var(--ll-sidebar-item-icon-color);
  background-color: var(--ll-sidebar-item-background-color);
  cursor: pointer;

  /** HOVER VARIANT **/
  &:hover {
    --ll-sidebar-item-label-color: ${(props) => props.theme.colors.neutral.c100};
    --ll-sidebar-item-icon-color: ${(props) => props.theme.colors.primary.c80};
    --ll-sidebar-item-background-color: unset;
  }

  /** FOCUS VARIANT **/
  &:focus {
    box-shadow: 0px 0px 0px 4px rgba(187, 176, 255, 0.4);
    border-radius: ${(p) => p.theme.space[3]}px;
  }

  /** ACTIVE VARIANT **/
  &[data-active="true"] {
    --ll-sidebar-item-label-color: ${(props) => props.theme.colors.neutral.c100};
    --ll-sidebar-item-icon-color: ${(props) => props.theme.colors.primary.c80};
    --ll-sidebar-item-background-color: ${(props) => props.theme.colors.primary.c20};
  }

  /** DISABLE VARIANT **/
  &[data-disable="true"] {
    --ll-sidebar-item-label-color: ${(props) => props.theme.colors.neutral.c80};
    --ll-sidebar-item-icon-color: ${(props) => props.theme.colors.neutral.c80};
    --ll-sidebar-item-background-color: unset;
    opacity: 0.3;
    cursor: unset;
    pointer-events: none;
  }
`;
const CollapsedBadgeContainer = import_styled_components.default.div`
  position: absolute;
  margin-top: -${(p) => p.theme.space[11]}px;
  margin-left: ${(p) => p.theme.space[8]}px;
`;
const DefaultBadge = import_styled_components.default.div`
  height: ${(p) => p.theme.space[4]}px;
  width: ${(p) => p.theme.space[4]}px;
  border-radius: ${(p) => p.theme.radii[2]}px;
  background-color: ${(p) => p.theme.colors.primary.c80};
`;
const ItemLabel = (0, import_styled_components.default)(import_Text.default)`
  display: inline-block;
  color: var(--ll-sidebar-item-label-color);

  text-transform: capitalize;
`;
const Item = ({
  label,
  children,
  onClick,
  isActive,
  isDisabled,
  displayNotificationBadge,
  customNotificationBadge
}) => {
  const { isExpanded } = (0, import_react.useContext)(import__.default);
  const handleClick = () => {
    if (isDisabled)
      return;
    onClick();
  };
  const badge = customNotificationBadge ?? /* @__PURE__ */ import_react.default.createElement(DefaultBadge, null);
  return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(
    ItemWrapper,
    {
      role: "button",
      onClick: handleClick,
      "data-active": isActive,
      "data-disable": isDisabled,
      tabIndex: 0
    },
    children,
    /* @__PURE__ */ import_react.default.createElement(CollapsedBadgeContainer, null, /* @__PURE__ */ import_react.default.createElement(
      import_TransitionInOut.default,
      {
        unmountOnExit: true,
        mountOnEnter: true,
        in: !isExpanded,
        style: { transitionDelay: !isExpanded ? "200ms" : 0 }
      },
      displayNotificationBadge && badge
    )),
    /* @__PURE__ */ import_react.default.createElement(
      import_TransitionInOut.default,
      {
        timeout: 200,
        in: isExpanded,
        unmountOnExit: true,
        mountOnEnter: true,
        style: { transitionDelay: isExpanded ? "200ms" : 0, display: "flex", flex: "1" }
      },
      /* @__PURE__ */ import_react.default.createElement(ItemLabel, { variant: "paragraph" }, label),
      /* @__PURE__ */ import_react.default.createElement(import_Flex.default, { alignItems: "center", justifyContent: "flex-end", ml: 2, flexGrow: 1 }, displayNotificationBadge && badge)
    )
  ));
};
var Item_default = Item;
//# sourceMappingURL=Item.js.map
