import { EntityListSubTree } from "@contember/binding";
import { Fragment } from "react";
import { jsxDEV } from "react/jsx-dev-runtime";
import { DataGridContainer } from "../base/DataGridContainer/DataGridContainer.js";
var _jsxFileName = "/__w/interface/interface/packages/admin/src/components/bindingFacade/collections/DataGrid/grid/renderGrid.tsx";
const renderGrid = ({
  setIsColumnHidden,
  setFilter,
  setOrderBy,
  updatePaging,
  setLayout
}, treeRootId, displayedState, desiredState, environment, containerProps = {}, component, componentProps) => {
  const {
    entities,
    paging: {
      pageIndex,
      itemsPerPage
    },
    hiddenColumns,
    filter,
    columns,
    orderBy
  } = displayedState;
  return /* @__PURE__ */ jsxDEV(EntityListSubTree, {
    entities: {
      ...entities,
      filter
    },
    treeRootId,
    offset: itemsPerPage === null ? void 0 : itemsPerPage * pageIndex,
    limit: itemsPerPage === null ? void 0 : itemsPerPage,
    orderBy,
    listComponent: component ?? DataGridContainer,
    listProps: {
      desiredState,
      displayedState,
      entityName: entities.entityName,
      filter,
      onEntityClick: containerProps.onEntityClick,
      selectedEntityKeys: containerProps.selectedEntityIds,
      tile: containerProps.tile,
      tileSize: containerProps.tileSize,
      setIsColumnHidden,
      setFilter,
      setOrderBy,
      setLayout,
      updatePaging,
      emptyMessageComponentExtraProps: containerProps.emptyMessageComponentExtraProps,
      emptyMessageComponent: containerProps.emptyMessageComponent,
      emptyMessage: containerProps.emptyMessage,
      ...componentProps
    },
    children: [containerProps.tile, Array.from(columns).filter(([key]) => !hiddenColumns[key]).map(([key, props]) => /* @__PURE__ */ jsxDEV(Fragment, {
      children: [props.header, props.children]
    }, key, true, {
      fileName: _jsxFileName,
      lineNumber: 66,
      columnNumber: 6
    }, void 0))]
  }, void 0, true, {
    fileName: _jsxFileName,
    lineNumber: 32,
    columnNumber: 3
  }, void 0);
};
export {
  renderGrid
};
//# sourceMappingURL=renderGrid.js.map
