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/ProcedureBody.tsx
var ProcedureBody_exports = {};
__export(ProcedureBody_exports, {
  default: () => ProcedureBody_default
});
module.exports = __toCommonJS(ProcedureBody_exports);
var import_react = __toESM(require("react"));
var import_pisellLayout = __toESM(require("../../pisellLayout"));
var import_ProcedureContent = __toESM(require("./ProcedureContent"));
var import_ProcedureSidebar = __toESM(require("./ProcedureSidebar"));
var import_ProcedureFooter = __toESM(require("./ProcedureFooter"));
var import_utils = require("../utils");
var ProcedureBody = ({
  bodyProps,
  footerProps,
  footerPosition,
  showFooter = true,
  showSidebar = true,
  className,
  summaryModalOpen,
  onOpenSummaryModal,
  onCloseSummaryModal,
  goPrev,
  goNext,
  mode = "page",
  containerSize,
  responsiveClsComputed
}) => {
  const direction = (bodyProps == null ? void 0 : bodyProps.direction) || "horizontal";
  const contentOrder = (bodyProps == null ? void 0 : bodyProps.contentOrder) || "content-first";
  const layoutMode = (bodyProps == null ? void 0 : bodyProps.layoutMode) || "fixed";
  const layoutRatio = (bodyProps == null ? void 0 : bodyProps.layoutRatio) || "7:3";
  const bodyCls = (0, import_react.useMemo)(() => {
    return (0, import_utils.mergeClassNames)(
      "pisell-procedure-body",
      className,
      bodyProps == null ? void 0 : bodyProps.className,
      // 添加排列方向类名
      `pisell-procedure-body--${direction}`,
      // 添加布局模式类名
      `pisell-procedure-body--${layoutMode}`,
      // 添加内容顺序类名
      `pisell-procedure-body--${contentOrder}`
    );
  }, [className, bodyProps == null ? void 0 : bodyProps.className, direction, layoutMode, contentOrder]);
  const ratioStyles = (0, import_react.useMemo)(() => {
    if (layoutMode !== "ratio") return null;
    return (0, import_utils.generateRatioStyles)(layoutRatio, 16);
  }, [layoutMode, layoutRatio]);
  const contentStyle = (0, import_react.useMemo)(() => {
    if (layoutMode === "ratio" && ratioStyles) {
      return { ...ratioStyles.contentStyle, ...bodyProps == null ? void 0 : bodyProps.contentStyle };
    }
    return bodyProps == null ? void 0 : bodyProps.contentStyle;
  }, [layoutMode, ratioStyles, bodyProps == null ? void 0 : bodyProps.contentStyle]);
  const sidebarStyle = (0, import_react.useMemo)(() => {
    if (layoutMode === "ratio" && ratioStyles) {
      return { ...ratioStyles.sidebarStyle, ...bodyProps == null ? void 0 : bodyProps.sidebarStyle };
    }
    return bodyProps == null ? void 0 : bodyProps.sidebarStyle;
  }, [layoutMode, ratioStyles, bodyProps == null ? void 0 : bodyProps.sidebarStyle]);
  const sidebarContent = bodyProps == null ? void 0 : bodyProps.sidebarSlot;
  const contentFooter = (0, import_react.useMemo)(() => {
    if (!showFooter || !(0, import_utils.isFooterInContent)(footerPosition)) return null;
    return /* @__PURE__ */ import_react.default.createElement(
      import_ProcedureFooter.default,
      {
        footerProps,
        position: footerPosition,
        sidebarContent,
        summaryModalOpen,
        onOpenSummaryModal,
        onCloseSummaryModal,
        goPrev,
        goNext,
        mode
      }
    );
  }, [showFooter, footerPosition, footerProps, sidebarContent, summaryModalOpen, onOpenSummaryModal, onCloseSummaryModal, goPrev, goNext, mode]);
  const sidebarFooter = (0, import_react.useMemo)(() => {
    if (!showFooter || !(0, import_utils.isFooterInSidebar)(footerPosition)) return null;
    return /* @__PURE__ */ import_react.default.createElement(
      import_ProcedureFooter.default,
      {
        footerProps,
        position: footerPosition,
        sidebarContent,
        summaryModalOpen,
        onOpenSummaryModal,
        onCloseSummaryModal,
        goPrev,
        goNext,
        mode
      }
    );
  }, [showFooter, footerPosition, footerProps, sidebarContent, summaryModalOpen, onOpenSummaryModal, onCloseSummaryModal, goPrev, goNext, mode]);
  const layoutStyle = (0, import_react.useMemo)(() => ({
    flexDirection: direction === "vertical" ? "column" : "row"
  }), [direction]);
  const contentComponent = /* @__PURE__ */ import_react.default.createElement(
    import_ProcedureContent.default,
    {
      className: bodyProps == null ? void 0 : bodyProps.contentClassName,
      style: contentStyle,
      extra: contentFooter
    },
    bodyProps == null ? void 0 : bodyProps.contentSlot
  );
  const sidebarComponent = showSidebar ? /* @__PURE__ */ import_react.default.createElement(
    import_ProcedureSidebar.default,
    {
      className: bodyProps == null ? void 0 : bodyProps.sidebarClassName,
      style: sidebarStyle,
      extra: sidebarFooter,
      isRatioMode: layoutMode === "ratio",
      containerSelector: bodyProps == null ? void 0 : bodyProps.sidebarContainerSelector,
      mode,
      direction,
      containerSize,
      responsiveClsComputed
    },
    bodyProps == null ? void 0 : bodyProps.sidebarSlot
  ) : null;
  const orderedChildren = (0, import_react.useMemo)(() => {
    if (contentOrder === "sidebar-first") {
      return [sidebarComponent, contentComponent].filter(Boolean);
    }
    return [contentComponent, sidebarComponent].filter(Boolean);
  }, [contentOrder, contentComponent, sidebarComponent]);
  return /* @__PURE__ */ import_react.default.createElement("div", { className: bodyCls, style: bodyProps == null ? void 0 : bodyProps.style }, /* @__PURE__ */ import_react.default.createElement(import_pisellLayout.default, { style: layoutStyle }, orderedChildren));
};
ProcedureBody.displayName = "ProcedureBody";
var ProcedureBody_default = ProcedureBody;
