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/PisellProcedure/components/ProcedureSidebar.tsx
var ProcedureSidebar_exports = {};
__export(ProcedureSidebar_exports, {
  default: () => ProcedureSidebar_default
});
module.exports = __toCommonJS(ProcedureSidebar_exports);
var import_react = __toESM(require("react"));
var import_sider = __toESM(require("../../pisellLayout/sider"));
var import_utils = require("../utils");
var import_hooks = require("../hooks");
var ProcedureSidebar = ({
  className,
  style,
  children,
  extra,
  isRatioMode = false,
  containerSelector,
  mode = "page",
  direction = "horizontal",
  containerSize,
  responsiveClsComputed
}) => {
  const isVertical = direction === "vertical";
  const headerSize = (0, import_hooks.useElementSize)({
    selector: ".pisell-procedure-header",
    enabled: !isVertical
  });
  const floatAllFooterSize = (0, import_hooks.useElementSize)({
    selector: ".pisell-procedure-footer--float-all",
    enabled: !isVertical
  });
  const fixedBottomFooterSize = (0, import_hooks.useElementSize)({
    selector: ".pisell-procedure-footer--fixed-bottom",
    enabled: !isVertical
  });
  const footerHeight = Math.max(
    (floatAllFooterSize == null ? void 0 : floatAllFooterSize.height) || 0,
    (fixedBottomFooterSize == null ? void 0 : fixedBottomFooterSize.height) || 0
  );
  const containerWidth = (containerSize == null ? void 0 : containerSize.width) || 0;
  (0, import_react.useEffect)(() => {
    if (typeof document === "undefined") return;
    const root = document.documentElement;
    if (containerWidth > 0) {
      root.style.setProperty(
        "--pisell-procedure-container-width",
        `${containerWidth}px`
      );
    }
    return () => {
      root.style.removeProperty("--pisell-procedure-container-width");
    };
  }, [containerWidth]);
  const isSizeStable = (0, import_react.useMemo)(() => {
    if (isVertical) {
      return false;
    }
    if (!(headerSize == null ? void 0 : headerSize.height) || headerSize.height === 0) {
      return false;
    }
    if (containerSelector && containerSelector.trim()) {
      return (containerSize == null ? void 0 : containerSize.width) > 0 && (containerSize == null ? void 0 : containerSize.height) > 0;
    }
    return true;
  }, [
    isVertical,
    containerSelector,
    containerSize == null ? void 0 : containerSize.width,
    containerSize == null ? void 0 : containerSize.height,
    headerSize == null ? void 0 : headerSize.height
  ]);
  const siderHeight = (0, import_hooks.useSidebarHeight)(isSizeStable, {
    containerSelector,
    containerHeight: containerSize == null ? void 0 : containerSize.height,
    headerHeight: headerSize == null ? void 0 : headerSize.height,
    footerHeight
  });
  const responsiveCls = mode === "modal" ? responsiveClsComputed : "";
  const sidebarCls = (0, import_react.useMemo)(() => {
    return (0, import_utils.mergeClassNames)(
      "pisell-procedure-sidebar",
      className,
      isRatioMode && "pisell-procedure-sidebar--ratio"
      // responsiveCls
    );
  }, [className, isRatioMode, responsiveCls]);
  const _height = (0, import_react.useMemo)(() => {
    if (mode === "modal") {
      return "100%";
    }
    if (siderHeight && siderHeight > 0) {
      return `${siderHeight}px`;
    }
  }, [mode, siderHeight]);
  return /* @__PURE__ */ import_react.default.createElement(
    import_sider.default,
    {
      className: sidebarCls
    },
    /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-procedure-sider-content-top" }, children),
    extra
  );
};
ProcedureSidebar.displayName = "ProcedureSidebar";
var ProcedureSidebar_default = ProcedureSidebar;
