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/PisellBasicGrid/PisellBasicGrid.tsx
var PisellBasicGrid_exports = {};
__export(PisellBasicGrid_exports, {
  PisellBasicGrid: () => MemoizedPisellBasicGrid,
  default: () => PisellBasicGrid_default
});
module.exports = __toCommonJS(PisellBasicGrid_exports);
var import_react = __toESM(require("react"));
var import_classnames = __toESM(require("classnames"));
var import_hooks = require("./hooks");
var import_utils = require("./utils");
var import_PisellBasicGrid = require("./PisellBasicGrid.less");
var PisellBasicGrid = (props) => {
  const {
    // 基础属性
    children,
    className,
    style,
    // 布局属性
    direction = "horizontal",
    wrap = "nowrap",
    columns,
    equalWidth = false,
    // 间距属性
    gap,
    rowGap,
    columnGap,
    // 对齐属性
    justify = "start",
    align = "stretch",
    alignContent = "stretch",
    // 数据源属性
    dataSource,
    renderItem,
    rowKey,
    startSlot,
    endSlot
  } = props;
  const { containerStyle, itemStyle } = (0, import_hooks.useGridStyle)({
    direction,
    wrap,
    columns,
    equalWidth,
    gap,
    rowGap,
    columnGap,
    justify,
    align,
    alignContent
  });
  const mergedStyle = (0, import_react.useMemo)(() => {
    return {
      ...containerStyle,
      ...style
    };
  }, [containerStyle, style]);
  const renderContent = () => {
    if (dataSource === void 0) {
      if (columns !== void 0 || equalWidth) {
        return import_react.default.Children.map(children, (child, index) => {
          if (!import_react.default.isValidElement(child)) {
            return child;
          }
          return /* @__PURE__ */ import_react.default.createElement(
            "div",
            {
              key: child.key ?? index,
              className: `${import_utils.COMPONENT_PREFIX}-item`,
              style: itemStyle
            },
            child
          );
        });
      }
      return children;
    }
    if (dataSource.length === 0) {
      return null;
    }
    return dataSource.map((item, index) => {
      const key = (0, import_utils.getRowKey)(item, index, rowKey);
      const content = renderItem == null ? void 0 : renderItem(item, index);
      return /* @__PURE__ */ import_react.default.createElement("div", { key, className: `${import_utils.COMPONENT_PREFIX}-item`, style: itemStyle }, content);
    });
  };
  return /* @__PURE__ */ import_react.default.createElement(
    "div",
    {
      className: (0, import_classnames.default)(import_utils.COMPONENT_PREFIX, className),
      style: mergedStyle
    },
    startSlot,
    " ",
    renderContent(),
    " ",
    endSlot
  );
};
var MemoizedPisellBasicGrid = (0, import_react.memo)(PisellBasicGrid);
var PisellBasicGrid_default = MemoizedPisellBasicGrid;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  PisellBasicGrid
});
