var _excluded = ["render", "columns", "rowKey", "rowSelection"],
  _excluded2 = ["autoCalc"],
  _excluded3 = ["onScroll"],
  _excluded4 = ["summary"];
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
import React, { useMemo, useRef, useState, useEffect } from 'react';
import classNames from 'classnames';
import { Table, Spin } from 'antd';
import { useRecordBoardContext } from "../../hooks/useRecordBoardContext";
import { processColumnsForGrid, getRecordBoardColumnKey, computeUniformColumnSummary, isTrivialUniformSummaryReactContent } from "../../utils/recordBoardColumns";
import { resolveRecordBoardPhoneScrollX } from "../../utils/recordBoardPhoneGrid";
import { getText } from "../../../../locales";
import "./Grid.less";
function getRowKey(record, rowKey) {
  var _ref, _record$id;
  if (typeof rowKey === 'function') {
    return rowKey(record);
  }
  if (typeof rowKey === 'string' && record != null && rowKey in record) {
    return record[rowKey];
  }
  return (_ref = (_record$id = record === null || record === void 0 ? void 0 : record.id) !== null && _record$id !== void 0 ? _record$id : record === null || record === void 0 ? void 0 : record.key) !== null && _ref !== void 0 ? _ref : record;
}

/**
 * Grid 布局下的数据视图：使用 antd Table，从 context 取 data / loading / 多选态。
 */
/** Context 中与 Table 无关的 key，透传 Table 时排除，避免覆盖或无效传递（含 grid 合并进的 columns/scroll 等） */
var CONTEXT_ONLY_KEYS = ['data', 'loading', 'total', 'pagination', 'onPageChange', 'searchParams', 'onSearch', 'onReset', 'layoutType', 'selectedKeys', 'selectedRows', 'onSelectionChange', 'rowKey', 'childComponentProps', 'columnVisibility', 'onColumnVisibilityChange', 'columns', 'scroll', 'size', 'defaultHiddenColumnKeys', 'scrollAreaHeight', 'setScrollAreaHeight', 'collapseUniformColumns', 'columnOrder', 'onColumnOrderChange', 'gridInfiniteScroll', 'infiniteScroll', 'paginationRender', 'layoutVariant', 'phoneColumnWidthCaps', 'phoneColumnWidthRatioByKey', 'phoneColumnWidthRatio'];
var RecordBoardGridView = function RecordBoardGridView(props) {
  var _ref2, _ctx$data2, _ctx$data4;
  var ctx = useRecordBoardContext({
    displayName: 'grid'
  });
  var render = props.render,
    columnsProp = props.columns,
    rowKeyProp = props.rowKey,
    rowSelectionProp = props.rowSelection,
    rest = _objectWithoutProperties(props, _excluded);

  // columns 优先用 props，其次用 childComponentProps.grid 合并进 ctx 的 columns
  var rawColumns = (_ref2 = columnsProp !== null && columnsProp !== void 0 ? columnsProp : ctx.columns) !== null && _ref2 !== void 0 ? _ref2 : [];
  var columnVisibility = ctx.columnVisibility;
  var columnOrder = ctx.columnOrder;
  var collapseUniformColumns = ctx.collapseUniformColumns !== false;
  var isPhoneLayout = ctx.layoutVariant === 'phone';
  var gridClassName = typeof ctx.className === 'string' ? ctx.className : undefined;

  /** 同值列总结区高度，用于 autoCalc 时正确计算 scroll.y */
  var summaryRef = useRef(null);
  var _useState = useState(0),
    _useState2 = _slicedToArray(_useState, 2),
    uniformSummaryHeight = _useState2[0],
    setUniformSummaryHeight = _useState2[1];
  var _useMemo = useMemo(function () {
      var _ctx$data;
      var list = rawColumns;
      if (Array.isArray(columnOrder) && columnOrder.length > 0) {
        var keyToCol = new Map(list.map(function (c) {
          return [getRecordBoardColumnKey(c), c];
        }));
        var ordered = [];
        var _iterator = _createForOfIteratorHelper(columnOrder),
          _step;
        try {
          for (_iterator.s(); !(_step = _iterator.n()).done;) {
            var key = _step.value;
            var col = keyToCol.get(key);
            if (col) ordered.push(col);
          }
        } catch (err) {
          _iterator.e(err);
        } finally {
          _iterator.f();
        }
        list.forEach(function (col) {
          var key = getRecordBoardColumnKey(col);
          if (!columnOrder.includes(key)) ordered.push(col);
        });
        list = ordered;
      }
      var visibleByUser = columnVisibility == null ? list : list.filter(function (col) {
        return columnVisibility[getRecordBoardColumnKey(col)] !== false;
      });
      var data = (_ctx$data = ctx.data) !== null && _ctx$data !== void 0 ? _ctx$data : [];
      var shouldCollapseUniform = collapseUniformColumns && data.length > 5;
      if (!shouldCollapseUniform) {
        return {
          columns: processColumnsForGrid(visibleByUser),
          uniformSummaryItems: [],
          processedColumnsForSummary: undefined
        };
      }
      var processedAllVisible = processColumnsForGrid(visibleByUser);
      var _computeUniformColumn = computeUniformColumnSummary(data, visibleByUser),
        uniformHiddenColumnKeys = _computeUniformColumn.uniformHiddenColumnKeys,
        items = _computeUniformColumn.summaryItems;

      /** 有 render 时以实际渲染为准：「-」、空等不展示总结项；列仍按折叠规则隐藏 */
      var finalSummaryItems = items.filter(function (item) {
        var _item$record, _item$displayValue;
        var processedCol = processedAllVisible.find(function (c) {
          return getRecordBoardColumnKey(c) === item.columnKey;
        });
        var useRender = typeof (processedCol === null || processedCol === void 0 ? void 0 : processedCol.render) === 'function';
        var content = useRender ? processedCol.render(item.cellValue, (_item$record = item.record) !== null && _item$record !== void 0 ? _item$record : {}, 0) : item.type === 'empty' ? getText('record-board-uniform-summary-empty') : (_item$displayValue = item.displayValue) !== null && _item$displayValue !== void 0 ? _item$displayValue : getText('record-board-uniform-summary-same');
        return !isTrivialUniformSummaryReactContent(content);
      });
      var columnsForTable = processedAllVisible.filter(function (col) {
        return !uniformHiddenColumnKeys.includes(getRecordBoardColumnKey(col));
      });
      return {
        columns: columnsForTable,
        uniformSummaryItems: finalSummaryItems,
        processedColumnsForSummary: finalSummaryItems.length > 0 ? processedAllVisible : undefined
      };
    }, [rawColumns, columnVisibility, columnOrder, collapseUniformColumns, ctx.data, isPhoneLayout]),
    columns = _useMemo.columns,
    summaryItems = _useMemo.uniformSummaryItems,
    processedColumnsForSummary = _useMemo.processedColumnsForSummary;
  var tableRowKey = useMemo(function () {
    var _ref3, _ctx$rowKey;
    var key = (_ref3 = (_ctx$rowKey = ctx.rowKey) !== null && _ctx$rowKey !== void 0 ? _ctx$rowKey : rowKeyProp) !== null && _ref3 !== void 0 ? _ref3 : 'id';
    return typeof key === 'function' ? key : function (record) {
      return getRowKey(record, typeof key === 'string' ? key : String(key));
    };
  }, [ctx.rowKey, rowKeyProp]);
  var rowSelectionConfig = rowSelectionProp !== null && rowSelectionProp !== void 0 ? rowSelectionProp : ctx.rowSelection;
  var rowSelection = useMemo(function () {
    if (rowSelectionConfig === false) return undefined;
    var base = _typeof(rowSelectionConfig) === 'object' ? rowSelectionConfig : {};
    return _objectSpread(_objectSpread({}, base), {}, {
      selectedRowKeys: ctx.selectedKeys,
      onChange: function onChange(selectedRowKeys, selectedRows) {
        var _onChange, _ref4;
        ctx.onSelectionChange(selectedRowKeys, selectedRows);
        (_onChange = (_ref4 = base).onChange) === null || _onChange === void 0 || _onChange.call(_ref4, selectedRowKeys, selectedRows);
      }
    });
  }, [ctx.selectedKeys, ctx.onSelectionChange, rowSelectionConfig]);

  /** 测量同值列总结区高度，供 autoCalc 时 scroll.y 减去该高度 */
  useEffect(function () {
    if (summaryItems.length === 0) {
      setUniformSummaryHeight(0);
      return;
    }
    var el = summaryRef.current;
    if (!el) return;
    var ro = new ResizeObserver(function (entries) {
      var entry = entries[0];
      if (entry) setUniformSummaryHeight(entry.contentRect.height);
    });
    ro.observe(el);
    return function () {
      ro.disconnect();
      setUniformSummaryHeight(0);
    };
  }, [summaryItems.length]);

  // grid 透传的 Table props（onRow、onHeaderRow、expandable、rowClassName、summary 等）从 ctx 取出并传给 Table
  var gridTableProps = useMemo(function () {
    var picked = {};
    Object.keys(ctx).forEach(function (k) {
      if (k === 'onScroll') return;
      if (CONTEXT_ONLY_KEYS.includes(k)) return;
      picked[k] = ctx[k];
    });
    return picked;
  }, [ctx]);
  if (typeof render === 'function') {
    return /*#__PURE__*/React.createElement(React.Fragment, null, render(_objectSpread(_objectSpread({}, ctx), rest)));
  }
  var dataSource = (_ctx$data2 = ctx.data) !== null && _ctx$data2 !== void 0 ? _ctx$data2 : [];
  var isEmpty = !Array.isArray(dataSource) || dataSource.length === 0;
  var sumColumnWidths = useMemo(function () {
    var sum = columns.reduce(function (acc, col) {
      if (typeof col.width === 'number' && Number.isFinite(col.width)) {
        return acc + col.width;
      }
      return isPhoneLayout ? acc : acc + 250;
    }, 0);
    if (sum > 0) {
      return sum;
    }
    return isPhoneLayout ? 0 : 2000;
  }, [columns, isPhoneLayout]);
  var selectionColumnWidth = useMemo(function () {
    if (!rowSelection || _typeof(rowSelection) !== 'object') return 0;
    var w = rowSelection.columnWidth;
    return typeof w === 'number' && Number.isFinite(w) ? w : 48;
  }, [rowSelection]);
  var gridInfiniteScroll = ctx.gridInfiniteScroll === true;

  // 与 materials Table useGenScroll 对齐：autoCalc 时根据 scrollAreaHeight 计算 scroll.y；无数据且 scroll.x 非数字时用列宽之和避免表头被压窄换行
  var tableScroll = useMemo(function () {
    var _rest$scroll;
    var scroll = (_rest$scroll = rest.scroll) !== null && _rest$scroll !== void 0 ? _rest$scroll : ctx.scroll;
    var rawScrollX = isEmpty && scroll && typeof scroll.x !== 'number' ? sumColumnWidths : scroll === null || scroll === void 0 ? void 0 : scroll.x;
    var scrollX = isPhoneLayout ? resolveRecordBoardPhoneScrollX(rawScrollX, sumColumnWidths, {
      selectionColumnWidth: selectionColumnWidth
    }) : rawScrollX;
    if (scroll !== null && scroll !== void 0 && scroll.autoCalc && typeof ctx.scrollAreaHeight === 'number') {
      var wrapHeight = ctx.scrollAreaHeight;
      // 40：表头固定高；uniformSummaryHeight：同值列总结区高度（ResizeObserver 量出，仅 content-box，不含 padding/border）；
      // 25：仅在确实展示 uniformSummary 时补回 padding 12*2 + 1px border-bottom（见 Grid.less .pisell-record-board-uniform-summary）。
      // 无总结时不应再多扣，否则 Table 不能撑满 scroll-body，会在 Table 与底部分页之间留白。
      var reservedHeight = 40 + (uniformSummaryHeight > 0 ? uniformSummaryHeight + 25 : 0);
      return {
        x: scrollX !== null && scrollX !== void 0 ? scrollX : sumColumnWidths,
        y: Math.max(wrapHeight - reservedHeight, 100),
        scrollToFirstRowOnChange: gridInfiniteScroll ? false : scroll.scrollToFirstRowOnChange
      };
    }
    if (scroll && _typeof(scroll) === 'object') {
      var _ref5 = scroll,
        _a = _ref5.autoCalc,
        restScroll = _objectWithoutProperties(_ref5, _excluded2);
      var resolved = Object.keys(restScroll).length ? restScroll : undefined;
      if (resolved) {
        var _ref6;
        return _objectSpread(_objectSpread({}, resolved), {}, {
          x: (_ref6 = scrollX !== null && scrollX !== void 0 ? scrollX : resolved.x) !== null && _ref6 !== void 0 ? _ref6 : sumColumnWidths
        }, gridInfiniteScroll ? {
          scrollToFirstRowOnChange: false
        } : {});
      }
      return resolved;
    }
    return scroll;
  }, [rest.scroll, ctx.scroll, ctx.scrollAreaHeight, ctx.pagination, columns, sumColumnWidths, isEmpty, uniformSummaryHeight, gridInfiniteScroll, isPhoneLayout, selectionColumnWidth]);

  /** 触底加载下一页：距底部约 48px 内触发，避免 loading 与重复 onPageChange */
  var infiniteLoadLockRef = useRef(false);
  /** 已触发 onPageChange、等待下一页数据：宿主可能不设 ctx.loading，需单独驱动表尾「加载中」 */
  var _useState3 = useState(false),
    _useState4 = _slicedToArray(_useState3, 2),
    infiniteScrollFetching = _useState4[0],
    setInfiniteScrollFetching = _useState4[1];
  // 与 dataSource.length 组合：宿主若不在请求期间置 loading，仅靠 loading 无法在下一次数据追加后清锁
  useEffect(function () {
    if (!ctx.loading) {
      infiniteLoadLockRef.current = false;
    }
  }, [ctx.loading, dataSource.length]);
  useEffect(function () {
    setInfiniteScrollFetching(false);
  }, [dataSource.length]);

  /**
   * 无限滚动：监听**实际发生滚动**的节点。
   * - 有 `scroll.y` 时表体在内部滚动，类名在 ConfigProvider 下为 `.pisell-lowcode-table-body`（非 `.ant-table-body`）；
   * - `scrollAreaHeight` 未就绪或仅 `autoCalc` 未算高时，整表在 Shell 的 `.pisell-record-board-scroll-body` 内滚，仅绑表体会漏事件（如 HUD 抽屉内嵌表）。
   */
  var gridWrapRef = useRef(null);
  var ctxRef = useRef(ctx);
  ctxRef.current = ctx;
  var restRef = useRef(rest);
  restRef.current = rest;
  var gridInfiniteRef = useRef(false);
  gridInfiniteRef.current = gridInfiniteScroll;
  useEffect(function () {
    if (!gridInfiniteScroll) return;
    var root = gridWrapRef.current;
    if (!root) {
      return;
    }
    var handler = function handler(e) {
      var _r$onScroll, _onScroll2, _ref7, _e$currentTarget, _c$data, _c$total;
      var r = restRef.current;
      var c = ctxRef.current;
      var ev = e;
      (_r$onScroll = r.onScroll) === null || _r$onScroll === void 0 || _r$onScroll.call(r, ev);
      (_onScroll2 = (_ref7 = c).onScroll) === null || _onScroll2 === void 0 || _onScroll2.call(_ref7, ev);
      if (!gridInfiniteRef.current) return;
      if (c.loading || infiniteLoadLockRef.current) {
        return;
      }
      var st = (_e$currentTarget = e.currentTarget) !== null && _e$currentTarget !== void 0 ? _e$currentTarget : e.target;
      var dataLen = ((_c$data = c.data) !== null && _c$data !== void 0 ? _c$data : []).length;
      var tot = (_c$total = c.total) !== null && _c$total !== void 0 ? _c$total : 0;
      var scrollTop = st.scrollTop,
        clientHeight = st.clientHeight,
        scrollHeight = st.scrollHeight;
      var dist = scrollHeight - scrollTop - clientHeight;
      if (dataLen >= tot) {
        return;
      }
      if (dist > 48) return;
      infiniteLoadLockRef.current = true;
      setInfiniteScrollFetching(true);
      c.onPageChange(c.pagination.pageNumber + 1, c.pagination.pageSize);
    };
    var listScrollTargets = function listScrollTargets(r) {
      var out = [];
      var seen = new Set();
      var add = function add(el) {
        if (el && !seen.has(el)) {
          seen.add(el);
          out.push(el);
        }
      };
      // 与 Grid.less 一致：项目 antd prefixCls 为 pisell-lowcode
      r.querySelectorAll('.ant-table-body, .pisell-lowcode-table-body').forEach(function (n) {
        return add(n);
      });
      // 虚拟表（grid.virtual）：antd 5 走 rc-virtual-list，真正滚动的是 holder，
      // 而 .ant-table-body 本身不滚 → 必须额外监听 holder，否则触底翻页（无限滚动）失效。
      r.querySelectorAll('.rc-virtual-list-holder').forEach(function (n) {
        return add(n);
      });
      add(r.closest('.pisell-record-board-scroll-body'));
      return out;
    };
    var cleanups = [];
    var bind = function bind() {
      cleanups.forEach(function (fn) {
        return fn();
      });
      cleanups.length = 0;
      var targets = listScrollTargets(root);
      targets.forEach(function (el) {
        el.addEventListener('scroll', handler, {
          passive: true
        });
        cleanups.push(function () {
          return el.removeEventListener('scroll', handler);
        });
      });
    };
    var t0 = window.setTimeout(function () {
      return bind();
    }, 0);
    var t1 = window.setTimeout(function () {
      return bind();
    }, 120);
    var t2 = window.setTimeout(function () {
      return bind();
    }, 400);
    return function () {
      clearTimeout(t0);
      clearTimeout(t1);
      clearTimeout(t2);
      cleanups.forEach(function (fn) {
        return fn();
      });
    };
  }, [gridInfiniteScroll, dataSource.length, isEmpty, ctx.scrollAreaHeight, columns, summaryItems.length]);
  var tableRest = useMemo(function () {
    if (!gridInfiniteScroll) return rest;
    var _ref8 = rest,
      _onScroll = _ref8.onScroll,
      r = _objectWithoutProperties(_ref8, _excluded3);
    return r;
  }, [gridInfiniteScroll, rest]);
  var userGridSummary = gridTableProps.summary;
  var infiniteSummaryColSpan = useMemo(function () {
    var n = Array.isArray(columns) ? columns.length : 1;
    return n + (rowSelection ? 1 : 0);
  }, [columns, rowSelection]);

  /** 无限滚动：在 Table.Summary 内展示状态（与宿主 summary 合并） */
  var mergedTableSummary = useMemo(function () {
    if (!gridInfiniteScroll) {
      return userGridSummary;
    }
    return function (pageData) {
      var _ctx$data3;
      var userNode = typeof userGridSummary === 'function' ? userGridSummary(pageData) : userGridSummary;
      var len = ((_ctx$data3 = ctx.data) !== null && _ctx$data3 !== void 0 ? _ctx$data3 : []).length;
      var tot = ctx.total;
      var loading = !!ctx.loading;
      var loadingMore = loading || infiniteScrollFetching;
      var showBar = len > 0 || loadingMore;
      if (!showBar && !userNode) {
        return null;
      }
      var hasMore = tot == null || typeof tot !== 'number' ? true : len < tot;
      var allLoaded = typeof tot === 'number' && tot > 0 && len > 0 && len >= tot;
      var statusInner = null;
      if (showBar) {
        // 先有「已全部加载」再判断加载：只要还有总数意义上的后续条（hasMore）且本地已有展示行，表尾一律显示加载中（含未到触底、未置 loading / 未打 fetching 的中间态）
        if (allLoaded) {
          statusInner = /*#__PURE__*/React.createElement("span", {
            className: "pisell-record-board-infinite-scroll-tip-done"
          }, getText('record-board-infinite-scroll-all-loaded'));
        } else if (hasMore && len > 0) {
          statusInner = /*#__PURE__*/React.createElement("span", {
            className: "pisell-record-board-infinite-scroll-tip-loading"
          }, /*#__PURE__*/React.createElement(Spin, {
            size: "small"
          }), /*#__PURE__*/React.createElement("span", null, getText('record-board-infinite-scroll-loading-more')));
        }
      }
      var statusBlock = statusInner != null ? /*#__PURE__*/React.createElement(Table.Summary, {
        fixed: "bottom"
      }, /*#__PURE__*/React.createElement(Table.Summary.Row, {
        className: "pisell-record-board-infinite-scroll-summary-row"
      }, /*#__PURE__*/React.createElement(Table.Summary.Cell, {
        index: 0,
        colSpan: infiniteSummaryColSpan,
        align: "left"
      }, /*#__PURE__*/React.createElement("div", {
        className: "pisell-record-board-infinite-scroll-tip"
      }, statusInner)))) : null;
      if (!userNode && !statusBlock) return null;
      return /*#__PURE__*/React.createElement(React.Fragment, null, userNode, statusBlock);
    };
  }, [gridInfiniteScroll, userGridSummary, infiniteSummaryColSpan, ctx.data, ctx.total, ctx.loading, infiniteScrollFetching]);
  var _ref9 = gridTableProps,
    _userSummaryOmitted = _ref9.summary,
    gridTablePropsWithoutSummary = _objectWithoutProperties(_ref9, _excluded4);
  return /*#__PURE__*/React.createElement("div", {
    ref: gridWrapRef,
    "data-layout-slot": "grid",
    className: classNames('pisell-lowcode-record-board-grid', isPhoneLayout && 'pisell-record-board-grid--phone', gridClassName)
  }, summaryItems.length > 0 && /*#__PURE__*/React.createElement("div", {
    ref: summaryRef,
    className: "pisell-record-board-uniform-summary"
  }, summaryItems.map(function (item) {
    var _item$record2, _item$displayValue2;
    var processedCol = processedColumnsForSummary === null || processedColumnsForSummary === void 0 ? void 0 : processedColumnsForSummary.find(function (c) {
      return getRecordBoardColumnKey(c) === item.columnKey;
    });
    var useRender = typeof (processedCol === null || processedCol === void 0 ? void 0 : processedCol.render) === 'function';
    // render 只接收表格单元格相同的 (value, record)：value 固定用 cellValue（dataIndex 取值），绝不传 uniformCompare 的返回值
    var content = useRender ? processedCol.render(item.cellValue, (_item$record2 = item.record) !== null && _item$record2 !== void 0 ? _item$record2 : {}, 0) : item.type === 'empty' ? getText('record-board-uniform-summary-empty') : (_item$displayValue2 = item.displayValue) !== null && _item$displayValue2 !== void 0 ? _item$displayValue2 : getText('record-board-uniform-summary-same');
    return /*#__PURE__*/React.createElement("div", {
      key: item.columnKey,
      className: "pisell-record-board-uniform-summary-item"
    }, /*#__PURE__*/React.createElement("span", {
      className: "pisell-record-board-uniform-summary-label"
    }, item.title), /*#__PURE__*/React.createElement("span", {
      className: "pisell-record-board-uniform-summary-value"
    }, content));
  })), /*#__PURE__*/React.createElement(Table, _extends({}, tableRest, gridTablePropsWithoutSummary, {
    summary: mergedTableSummary,
    scroll: tableScroll,
    rowKey: tableRowKey,
    dataSource: (_ctx$data4 = ctx.data) !== null && _ctx$data4 !== void 0 ? _ctx$data4 : [],
    loading: ctx.loading,
    columns: columns,
    rowSelection: rowSelection,
    pagination: false
  })));
};
export default RecordBoardGridView;