import { useBuildEnvironment } from "../../shell/ui/useBuildEnvironment.mjs";
import { executeQueryAdHoc } from "../../udp/utilities/methodUtils.mjs";
import { useAgGridApi } from "../../utilities/aggrid/AgTable.mjs";
import { AmbientGridTemplate } from "../../UI/templates/deprecated/AmbientGridTemplate/AmbientGridTemplate.mjs";
import { ActionsRenderer } from "../../UI/templates/ui/renderers/ActionsRenderer.mjs";
import { TableColumnDefs } from "./TableColumnDefs.mjs";
import { SearchServiceDatasource } from "../../utilities/aggrid/datasources/SearchServiceDatasource.mjs";
import { c } from "react-compiler-runtime";
import React, { useEffect } from "react";
//#region src/maintenanceEngine/tableBrowser/TableContainer.jsx
const TableContainer = (props) => {
	const $ = c(55);
	let actionList;
	let additionalGridOptions;
	let api;
	let catalog;
	let columnApi;
	let customColumnDefs;
	let dynamicSizing;
	let filterElements;
	let gridReady;
	let headerBackgroundColor;
	let loading;
	let other;
	let promotedEntity;
	let rowData;
	let t0;
	let t1;
	let t2;
	let t3;
	if ($[0] !== props) {
		({actionList, loading, rowData, catalog, isServerSide: t0, promotedEntity, filterElements, customColumnDefs, eagerLoad: t1, logicalSearchOperator: t2, frameworkComponents: t3, additionalGridOptions, headerBackgroundColor, api, columnApi, gridReady, dynamicSizing, ...other} = props);
		$[0] = props;
		$[1] = actionList;
		$[2] = additionalGridOptions;
		$[3] = api;
		$[4] = catalog;
		$[5] = columnApi;
		$[6] = customColumnDefs;
		$[7] = dynamicSizing;
		$[8] = filterElements;
		$[9] = gridReady;
		$[10] = headerBackgroundColor;
		$[11] = loading;
		$[12] = other;
		$[13] = promotedEntity;
		$[14] = rowData;
		$[15] = t0;
		$[16] = t1;
		$[17] = t2;
		$[18] = t3;
	} else {
		actionList = $[1];
		additionalGridOptions = $[2];
		api = $[3];
		catalog = $[4];
		columnApi = $[5];
		customColumnDefs = $[6];
		dynamicSizing = $[7];
		filterElements = $[8];
		gridReady = $[9];
		headerBackgroundColor = $[10];
		loading = $[11];
		other = $[12];
		promotedEntity = $[13];
		rowData = $[14];
		t0 = $[15];
		t1 = $[16];
		t2 = $[17];
		t3 = $[18];
	}
	const isServerSide = t0 === void 0 ? false : t0;
	const eagerLoad = t1 === void 0 ? false : t1;
	const logicalSearchOperator = t2 === void 0 ? 1 : t2;
	let t4;
	if ($[19] !== t3) {
		t4 = t3 === void 0 ? { actionsRenderer: ActionsRenderer } : t3;
		$[19] = t3;
		$[20] = t4;
	} else t4 = $[20];
	const frameworkComponents = t4;
	const { gridApi, gridColumnApi, onGridReady } = useAgGridApi();
	const gApi = api || gridApi;
	const cApi = columnApi || gridColumnApi;
	const gReady = gridReady || onGridReady;
	const buildEnv = useBuildEnvironment();
	let t5;
	if ($[21] !== actionList || $[22] !== customColumnDefs) {
		t5 = customColumnDefs || TableColumnDefs(actionList);
		$[21] = actionList;
		$[22] = customColumnDefs;
		$[23] = t5;
	} else t5 = $[23];
	const columnDefs = t5;
	let t6;
	if ($[24] !== columnDefs) {
		t6 = columnDefs?.map(_temp);
		$[24] = columnDefs;
		$[25] = t6;
	} else t6 = $[25];
	const groupData = t6;
	let t7;
	let t8;
	if ($[26] !== eagerLoad || $[27] !== filterElements || $[28] !== gApi || $[29] !== isServerSide || $[30] !== logicalSearchOperator || $[31] !== promotedEntity) {
		t7 = () => {
			if (!gApi) return;
			if (promotedEntity && isServerSide) {
				const datasource = SearchServiceDatasource(null, promotedEntity?.unityBaseSearchMethod?.apiMethodId, filterElements, logicalSearchOperator, executeQueryAdHoc, null, null, eagerLoad);
				gApi?.setServerSideDatasource(datasource);
			}
		};
		t8 = [
			gApi,
			promotedEntity,
			isServerSide,
			filterElements,
			eagerLoad,
			logicalSearchOperator
		];
		$[26] = eagerLoad;
		$[27] = filterElements;
		$[28] = gApi;
		$[29] = isServerSide;
		$[30] = logicalSearchOperator;
		$[31] = promotedEntity;
		$[32] = t7;
		$[33] = t8;
	} else {
		t7 = $[32];
		t8 = $[33];
	}
	useEffect(t7, t8);
	const t9 = catalog?.name;
	const t10 = !isServerSide && rowData;
	const t11 = `calc(100vh - ${buildEnv ? "139px" : "114px"})`;
	const t12 = dynamicSizing ?? false;
	const t13 = isServerSide ? "serverSide" : null;
	const t14 = isServerSide ? "partial" : null;
	const t15 = isServerSide ? 2 : null;
	const t16 = isServerSide ? 20 : null;
	const t17 = isServerSide ? 1 : null;
	let t18;
	if ($[34] !== additionalGridOptions || $[35] !== cApi || $[36] !== columnDefs || $[37] !== frameworkComponents || $[38] !== gApi || $[39] !== gReady || $[40] !== groupData || $[41] !== headerBackgroundColor || $[42] !== isServerSide || $[43] !== loading || $[44] !== other || $[45] !== t10 || $[46] !== t11 || $[47] !== t12 || $[48] !== t13 || $[49] !== t14 || $[50] !== t15 || $[51] !== t16 || $[52] !== t17 || $[53] !== t9) {
		t18 = /* @__PURE__ */ React.createElement(AmbientGridTemplate, {
			useNewHeader: true,
			api: gApi,
			onGridReady: gReady,
			columnApi: cApi,
			title: t9,
			data: t10,
			columnDefs,
			groupingData: groupData,
			height: t11,
			frameworkComponents,
			hideSearchBar: isServerSide,
			loading,
			suppressScrollOnNewData: true,
			dynamicSizing: t12,
			disableRowSelection: true,
			rowModelType: t13,
			serverSideStoreType: t14,
			cacheOverflowSize: t15,
			cacheBlockSize: t16,
			maxConcurrentDatasourceRequests: t17,
			additionalGridOptions,
			headerBackgroundColor,
			...other
		});
		$[34] = additionalGridOptions;
		$[35] = cApi;
		$[36] = columnDefs;
		$[37] = frameworkComponents;
		$[38] = gApi;
		$[39] = gReady;
		$[40] = groupData;
		$[41] = headerBackgroundColor;
		$[42] = isServerSide;
		$[43] = loading;
		$[44] = other;
		$[45] = t10;
		$[46] = t11;
		$[47] = t12;
		$[48] = t13;
		$[49] = t14;
		$[50] = t15;
		$[51] = t16;
		$[52] = t17;
		$[53] = t9;
		$[54] = t18;
	} else t18 = $[54];
	return t18;
};
function _temp(item) {
	return {
		groupItem: item.field,
		label: item.headerName,
		value: item.field
	};
}
//#endregion
export { TableContainer };

//# sourceMappingURL=TableContainer.mjs.map