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);

// src/components/PisellCards/components/MultilevelCard/MultilevelCard.tsx
var MultilevelCard_exports = {};
__export(MultilevelCard_exports, {
  MultilevelCard: () => MultilevelCard,
  default: () => MultilevelCard_default
});
module.exports = __toCommonJS(MultilevelCard_exports);
var import_react = __toESM(require("react"));
var import_react_dom = __toESM(require("react-dom"));
var import_classnames = __toESM(require("classnames"));
var import_components = require("./components");
var import_hooks = require("./hooks");
var import_MultilevelCard = require("./MultilevelCard.less");
var MultilevelCard = (props) => {
  const {
    card,
    panel,
    dataSource,
    active,
    disabled,
    loading,
    children,
    onClick,
    trigger = "click",
    hoverDelay,
    panelWidthMode = "full",
    panelWidth,
    panelStyle,
    panelClassName,
    panelContainer,
    animation = true,
    animationDuration = 300,
    onExpandChange,
    onPanelMount,
    onPanelUnmount,
    className,
    style,
    __designMode
  } = props;
  const { expanded, setExpanded } = (0, import_hooks.useMultilevelCardExpand)({
    active,
    trigger,
    onExpandChange
  });
  const { onMouseEnter, onMouseLeave } = (0, import_hooks.useMultilevelCardHover)({
    enabled: trigger === "hover",
    delay: hoverDelay,
    onExpandChange: setExpanded
  });
  (0, import_react.useEffect)(() => {
    document.body.id = "body";
  }, []);
  const renderPanel = () => {
    if (!panel || !expanded) {
      return null;
    }
    const panelElement = /* @__PURE__ */ import_react.default.createElement(
      import_components.PanelWrapper,
      {
        visible: expanded,
        widthMode: panelWidthMode,
        width: panelWidth,
        style: panelStyle,
        className: panelClassName,
        animation,
        animationDuration,
        onMount: onPanelMount,
        onUnmount: onPanelUnmount,
        onMouseEnter: trigger === "hover" ? onMouseEnter : void 0,
        onMouseLeave: trigger === "hover" ? onMouseLeave : void 0,
        props
      },
      panel == null ? void 0 : panel(props)
    );
    if ((panelContainer == null ? void 0 : panelContainer(props)) && typeof document !== "undefined") {
      return import_react_dom.default.createPortal(
        panelElement,
        panelContainer(props)
      );
    }
    return panelElement;
  };
  const multilevelCardClassName = (0, import_classnames.default)(
    "multilevel-card",
    {
      "multilevel-card--expanded": expanded,
      "multilevel-card--click": trigger === "click",
      "multilevel-card--hover": trigger === "hover"
    },
    className
  );
  return /* @__PURE__ */ import_react.default.createElement("div", { className: multilevelCardClassName, style }, /* @__PURE__ */ import_react.default.createElement(
    import_components.CardWrapper,
    {
      trigger,
      onMouseEnter,
      onMouseLeave,
      className: "multilevel-card__card"
    },
    card == null ? void 0 : card(props)
  ), renderPanel());
};
MultilevelCard.displayName = "MultilevelCard";
var Provider = (props) => /* @__PURE__ */ import_react.default.createElement(MultilevelCard, { ...props == null ? void 0 : props.props, ...props });
var MultilevelCard_default = Provider;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  MultilevelCard
});
