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/PisellSteps/PisellSteps.tsx
var PisellSteps_exports = {};
__export(PisellSteps_exports, {
  default: () => PisellSteps_default
});
module.exports = __toCommonJS(PisellSteps_exports);
var import_antd = require("antd");
var import_react = __toESM(require("react"));
var import_PisellSteps = require("./PisellSteps.less");
var import_hooks = require("./hooks");
var import_utils = require("./utils");
var import_PisellScrollView = __toESM(require("../PisellScrollView"));
var PisellSteps = ({
  // 基础属性
  type = "default",
  current: controlledCurrent,
  defaultCurrent = 0,
  direction = "horizontal",
  size = "default",
  status = "process",
  initial = 0,
  items = [],
  labelPlacement = "horizontal",
  responsive = true,
  onChange,
  className,
  style,
  progressDot,
  // 扩展功能属性
  clickable = false,
  allowClickFinished = true,
  gridLayout = false,
  gridColumns,
  itemGap,
  enableAnchor = false,
  anchorContainer,
  mobileMode = "full",
  mobileBreakpoint = 744,
  // 滚动模式属性
  enableScrollMode = false,
  scrollActionsConfig,
  // 低代码属性
  __designMode,
  __id,
  other,
  ...restProps
}) => {
  const [currentStep, setCurrentStep] = (0, import_hooks.useStepsState)(
    controlledCurrent,
    defaultCurrent,
    onChange
  );
  const handleStepClick = (0, import_hooks.useStepClick)(
    currentStep,
    clickable,
    allowClickFinished,
    setCurrentStep
  );
  (0, import_hooks.useAnchor)(currentStep, enableAnchor, anchorContainer);
  const isMobile = (0, import_hooks.useResponsive)(mobileBreakpoint);
  const showMobileCurrentView = (0, import_react.useMemo)(() => {
    if (mobileMode === "current") return true;
    if (mobileMode === "auto" && isMobile) return true;
    return false;
  }, [mobileMode, isMobile]);
  const safeItems = (0, import_react.useMemo)(() => {
    if (!items) return [];
    if (!Array.isArray(items)) return [];
    return items;
  }, [items]);
  const currentStepItem = (0, import_react.useMemo)(() => {
    const visibleItems = safeItems.filter((item) => !item.hidden);
    const adjustedIndex = currentStep - initial;
    if (adjustedIndex < 0 || adjustedIndex >= visibleItems.length) {
      return null;
    }
    return visibleItems[adjustedIndex] || null;
  }, [safeItems, currentStep, initial]);
  const processedItems = (0, import_react.useMemo)(() => {
    const visibleItems = safeItems.filter((item) => !item.hidden);
    if (__designMode === "design" && visibleItems.length === 0) {
      return [
        {
          title: "步骤一",
          description: "This is a description.",
          status: "finish"
        },
        {
          title: "步骤二",
          description: "This is a description.",
          status: "process"
        },
        {
          title: "步骤三",
          description: "This is a description.",
          status: "wait"
        }
      ];
    }
    return visibleItems.filter((item) => item != null).map((item, index) => {
      const adjustedIndex = index + initial;
      let stepStatus;
      if (item.status) {
        stepStatus = item.status;
      } else if (adjustedIndex === currentStep) {
        stepStatus = status;
      } else {
        stepStatus = (0, import_utils.getStepStatus)(adjustedIndex, currentStep);
      }
      const stepClassName = (0, import_utils.mergeStepClassName)(
        "pisell-steps-item",
        stepStatus,
        item.className
      );
      const handleClick = () => {
        var _a;
        if (!item.disabled) {
          (_a = item.onClick) == null ? void 0 : _a.call(item);
          handleStepClick(adjustedIndex, item);
        }
      };
      return {
        ...item,
        status: stepStatus,
        className: stepClassName,
        onClick: clickable || item.onClick ? handleClick : void 0
      };
    });
  }, [
    safeItems,
    currentStep,
    initial,
    status,
    clickable,
    handleStepClick,
    __designMode
  ]);
  const wrapperClassName = (0, import_react.useMemo)(() => {
    const classes = ["pisell-steps"];
    if (className) classes.push(className);
    if (type === "navigation") classes.push("pisell-steps-navigation");
    if (progressDot) classes.push("pisell-steps-dot");
    if (size !== "default") classes.push(`pisell-steps-${size}`);
    if (direction === "vertical") classes.push("pisell-steps-vertical");
    if (responsive) classes.push("pisell-steps-responsive");
    if (clickable) classes.push("pisell-steps-clickable");
    if (gridLayout) classes.push("pisell-steps-grid-layout");
    if (itemGap !== void 0 && itemGap !== null) {
      classes.push("pisell-steps-has-item-gap");
    }
    return classes.join(" ");
  }, [
    className,
    type,
    progressDot,
    size,
    direction,
    responsive,
    clickable,
    gridLayout,
    itemGap
  ]);
  const wrapperStyle = (0, import_react.useMemo)(() => {
    const customStyle = { ...style };
    if (itemGap !== void 0 && itemGap !== null) {
      customStyle["--pisell-steps-item-gap"] = `${itemGap}px`;
      customStyle["--pisell-steps-has-item-gap"] = "1";
    }
    if (gridColumns && gridLayout) {
      customStyle["--pisell-steps-grid-columns"] = gridColumns;
    }
    return customStyle;
  }, [style, itemGap, gridColumns, gridLayout]);
  const defaultScrollActionsConfig = (0, import_react.useMemo)(
    () => ({
      show: true,
      type: "lrArrows",
      scrollDistance: 200,
      ...scrollActionsConfig
    }),
    [scrollActionsConfig]
  );
  const renderStepsContent = (forceHorizontal = false) => /* @__PURE__ */ import_react.default.createElement(
    import_antd.Steps,
    {
      current: Math.max(0, currentStep - initial),
      direction: forceHorizontal ? "horizontal" : direction,
      size: size === "large" ? "default" : size,
      status,
      items: processedItems,
      labelPlacement,
      type,
      progressDot,
      responsive: forceHorizontal ? false : responsive,
      ...restProps,
      ...other || {}
    }
  );
  const renderDesktopSteps = () => {
    if (enableScrollMode) {
      return /* @__PURE__ */ import_react.default.createElement(
        import_PisellScrollView.default,
        {
          className: "pisell-steps-scroll-view",
          overflow: "x",
          scrollbarStyle: "none",
          scrollActionsConfig: defaultScrollActionsConfig,
          snapScroll: { enabled: false }
        },
        /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-steps-scroll-content" }, renderStepsContent(true))
      );
    }
    return renderStepsContent(false);
  };
  return /* @__PURE__ */ import_react.default.createElement(
    "div",
    {
      className: showMobileCurrentView ? `pisell-steps pisell-steps-mobile-current ${className || ""}` : wrapperClassName,
      style: showMobileCurrentView ? style : wrapperStyle,
      "data-component": "pisell-steps",
      "data-id": __id
    },
    showMobileCurrentView ? /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-steps-mobile-current__info" }, (currentStepItem == null ? void 0 : currentStepItem.title) && /* @__PURE__ */ import_react.default.createElement("span", { className: "pisell-steps-mobile-current__number" }, currentStepItem.title), (currentStepItem == null ? void 0 : currentStepItem.description) && /* @__PURE__ */ import_react.default.createElement("span", { className: "pisell-steps-mobile-current__title" }, currentStepItem.description)) : /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, renderDesktopSteps())
  );
};
PisellSteps.displayName = "PisellSteps";
var PisellSteps_default = PisellSteps;
