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/table/Gallery/components/GalleryItem/index.tsx
var GalleryItem_exports = {};
__export(GalleryItem_exports, {
  default: () => GalleryItem_default
});
module.exports = __toCommonJS(GalleryItem_exports);
var import_react = __toESM(require("react"));
var import_utils = require("@pisell/utils");
var import_Cover = __toESM(require("./components/Cover"));
var import_Title = __toESM(require("./components/Title"));
var import_classicLayout = __toESM(require("../../../../classicLayout"));
var import_RenderFields = __toESM(require("./components/RenderFields"));
var import_index = require("./index.less");
var prefix = "pisell-lowcode-";
var GalleryItem = (props) => {
  const { record, gallery, columnsMap, index, gallerySetting, columns, onClick } = props;
  const {
    coverField,
    coverObjectFit,
    compactMode,
    isShowLabel: propsIsShowLabel
  } = gallerySetting || {};
  const { cover, title, header, content, footer } = gallery;
  const { fields: headerFields, slot } = header || {};
  const { fields: contentFields } = content || {};
  const { render, height } = footer || {};
  const coverDom = (0, import_react.useMemo)(() => {
    return cover.show && coverField !== "noCover" && /* @__PURE__ */ import_react.default.createElement(
      import_Cover.default,
      {
        record,
        cover,
        coverField,
        coverObjectFit
      }
    );
  }, [record, cover, coverField, coverObjectFit]);
  const titleDom = (0, import_react.useMemo)(() => {
    return /* @__PURE__ */ import_react.default.createElement(import_Title.default, { columnsMap, record, ...title });
  }, [record, title, columnsMap]);
  const Header = (0, import_react.useMemo)(() => {
    return /* @__PURE__ */ import_react.default.createElement("div", { className: `${prefix}header-wrap` }, coverDom, titleDom, headerFields.show && /* @__PURE__ */ import_react.default.createElement(
      import_RenderFields.default,
      {
        record,
        showMode: "block",
        columnsMap,
        fields: headerFields.list,
        isShowLabel: true
      }
    ), slot && slot(record, index));
  }, [
    coverDom,
    columnsMap,
    record,
    cover,
    title,
    headerFields.show,
    headerFields.list,
    slot,
    index
  ]);
  const { fixedHeader, fixedFooter } = (0, import_react.useMemo)(() => {
    if (gallery.fixedHeight) {
      return {
        fixedHeader: gallery.fixedHeader,
        fixedFooter: gallery.fixedFooter
      };
    }
    return {
      fixedHeader: false,
      fixedFooter: false
    };
  }, [gallery.fixedHeight, gallery.fixedHeader, gallery.fixedFooter]);
  const { showMode, isShowLabel } = (0, import_react.useMemo)(() => {
    if (compactMode === "compact") {
      return {
        showMode: "inline",
        isShowLabel: false
      };
    } else if (compactMode === "default") {
      return {
        showMode: "block",
        isShowLabel: propsIsShowLabel
      };
    }
    return {
      showMode: "block",
      isShowLabel: propsIsShowLabel
    };
  }, [compactMode, propsIsShowLabel]);
  const Content = (0, import_react.useMemo)(() => {
    const showFieldList = [];
    columns.forEach((item) => {
      if (item.isShow) {
        showFieldList.push(item.key);
      }
    });
    return /* @__PURE__ */ import_react.default.createElement(
      import_RenderFields.default,
      {
        record,
        showMode,
        columnsMap,
        fields: showFieldList,
        isShowLabel
      }
    );
  }, [contentFields, record, columnsMap, showMode, isShowLabel, columns]);
  const Footer = (0, import_react.useMemo)(() => {
    return render && render(record, index);
  }, [record, index]);
  return /* @__PURE__ */ import_react.default.createElement("div", { className: `${prefix}gallery-item-wrap`, onClick }, /* @__PURE__ */ import_react.default.createElement(
    import_classicLayout.default,
    {
      fixedHeader,
      fixedFooter,
      header: Header,
      content: Content,
      footer: Footer,
      footerStyle: {
        height: (0, import_utils.isFunction)(render) ? height : 0
      }
    }
  ));
};
var GalleryItem_default = GalleryItem;
