import { ConfigService } from "../../../../configService/index.mjs";
import { SideSheet } from "../../../../UI/surfaces/SideSheet.mjs";
import { SearchMethodUdpGrid } from "../../../../UI/templates/newGrid/SearchMethodUdpGrid.mjs";
import UdpTransactionUiActionCreateAndEditSidesheet from "./UdpTransactionUiActionCreateAndEditSidesheet.mjs";
import { c } from "react-compiler-runtime";
import React, { forwardRef, useImperativeHandle, useRef } from "react";
import { useTranslation } from "react-i18next";
//#region src/udp/pages/UdpTransactionTypesPage/sidesheets/UdpTransactionUiActionSidesheet.jsx
const UdpTransactionUiActionSidesheet = (props, ref) => {
	const $ = c(84);
	const { transactionType, transactionUiAction, isSideSheetOpen, handleTransactionUiActionSidesheet, isCreateOrEditTransactionUiActionSidesheetOpen, handleCreateOrEditTransactionUiActionSidesheet, handleCreateTransactionUiAction, handleUpdateTransactionUiAction, handleDeleteTransactionUiAction, transactionUiActionTypes, actionApis, pages, tUiActionsList } = props;
	const transactionUiActionGridApiRef = useRef(null);
	const { t } = useTranslation();
	let t0;
	if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
		t0 = () => ({ refreshServerSide: () => {
			transactionUiActionGridApiRef?.current?.refreshServerSide();
		} });
		$[0] = t0;
	} else t0 = $[0];
	useImperativeHandle(ref, t0);
	let t1;
	if ($[1] !== transactionUiActionTypes) {
		t1 = (transactionUiActionTypeId) => {
			if (!transactionUiActionTypes) return "";
			return transactionUiActionTypes.find((transactionUiActionType) => transactionUiActionType.transactionUiActionTypeId === transactionUiActionTypeId)?.name || "";
		};
		$[1] = transactionUiActionTypes;
		$[2] = t1;
	} else t1 = $[2];
	const getTransactionUiActionTypeName = t1;
	let t2;
	if ($[3] !== t) {
		t2 = t("TransactionUiActionId");
		$[3] = t;
		$[4] = t2;
	} else t2 = $[4];
	let t3;
	if ($[5] !== t2) {
		t3 = {
			headerName: t2,
			field: "transactionUiActionId",
			resizable: true,
			sortable: false,
			hide: true
		};
		$[5] = t2;
		$[6] = t3;
	} else t3 = $[6];
	let t4;
	if ($[7] !== t) {
		t4 = t("Type");
		$[7] = t;
		$[8] = t4;
	} else t4 = $[8];
	let t5;
	if ($[9] !== getTransactionUiActionTypeName) {
		t5 = (params) => getTransactionUiActionTypeName(params.data.transactionUiActionTypeId);
		$[9] = getTransactionUiActionTypeName;
		$[10] = t5;
	} else t5 = $[10];
	let t6;
	if ($[11] !== t4 || $[12] !== t5) {
		t6 = {
			headerName: t4,
			field: "transactionUiActionTypeId",
			resizable: false,
			sortable: false,
			valueGetter: t5
		};
		$[11] = t4;
		$[12] = t5;
		$[13] = t6;
	} else t6 = $[13];
	let t7;
	if ($[14] !== t) {
		t7 = t("Actions");
		$[14] = t;
		$[15] = t7;
	} else t7 = $[15];
	let t8;
	if ($[16] !== t) {
		t8 = t("Edit");
		$[16] = t;
		$[17] = t8;
	} else t8 = $[17];
	let t9;
	if ($[18] !== handleCreateOrEditTransactionUiActionSidesheet) {
		t9 = (e, transactionUiAction_0) => {
			handleCreateOrEditTransactionUiActionSidesheet(true, transactionUiAction_0?.data);
		};
		$[18] = handleCreateOrEditTransactionUiActionSidesheet;
		$[19] = t9;
	} else t9 = $[19];
	let t10;
	if ($[20] !== t8 || $[21] !== t9) {
		t10 = {
			id: 0,
			title: t8,
			iconName: "edit",
			handleOnClick: t9
		};
		$[20] = t8;
		$[21] = t9;
		$[22] = t10;
	} else t10 = $[22];
	let t11;
	if ($[23] !== t) {
		t11 = t("Delete");
		$[23] = t;
		$[24] = t11;
	} else t11 = $[24];
	let t12;
	if ($[25] !== handleDeleteTransactionUiAction) {
		t12 = (e_0, transactionUiAction_1) => {
			handleDeleteTransactionUiAction(transactionUiAction_1?.data);
		};
		$[25] = handleDeleteTransactionUiAction;
		$[26] = t12;
	} else t12 = $[26];
	let t13;
	if ($[27] !== t11 || $[28] !== t12) {
		t13 = {
			id: 1,
			title: t11,
			iconName: "trashCan",
			handleOnClick: t12
		};
		$[27] = t11;
		$[28] = t12;
		$[29] = t13;
	} else t13 = $[29];
	let t14;
	if ($[30] !== t10 || $[31] !== t13) {
		t14 = { actionList: [t10, t13] };
		$[30] = t10;
		$[31] = t13;
		$[32] = t14;
	} else t14 = $[32];
	let t15;
	if ($[33] !== t14 || $[34] !== t7) {
		t15 = {
			headerName: t7,
			field: "actions",
			cellRenderer: "actionsRenderer",
			cellRendererParams: t14,
			suppressMenu: true,
			sortable: false,
			filter: false,
			valueGetter: _temp
		};
		$[33] = t14;
		$[34] = t7;
		$[35] = t15;
	} else t15 = $[35];
	let t16;
	if ($[36] !== t15 || $[37] !== t3 || $[38] !== t6) {
		t16 = [
			t3,
			t6,
			t15
		];
		$[36] = t15;
		$[37] = t3;
		$[38] = t6;
		$[39] = t16;
	} else t16 = $[39];
	const columnDefs = t16;
	let t17;
	if ($[40] !== t) {
		t17 = t("Form / Page Overrides");
		$[40] = t;
		$[41] = t17;
	} else t17 = $[41];
	let t18;
	if ($[42] !== t) {
		t18 = t("Add");
		$[42] = t;
		$[43] = t18;
	} else t18 = $[43];
	let t19;
	if ($[44] !== handleCreateOrEditTransactionUiActionSidesheet) {
		t19 = () => handleCreateOrEditTransactionUiActionSidesheet(true);
		$[44] = handleCreateOrEditTransactionUiActionSidesheet;
		$[45] = t19;
	} else t19 = $[45];
	let t20;
	if ($[46] !== t18 || $[47] !== t19) {
		t20 = {
			label: t18,
			iconName: "add",
			onClick: t19
		};
		$[46] = t18;
		$[47] = t19;
		$[48] = t20;
	} else t20 = $[48];
	let t21;
	if ($[49] !== t17 || $[50] !== t20) {
		t21 = {
			title: t17,
			primaryActionButton: t20
		};
		$[49] = t17;
		$[50] = t20;
		$[51] = t21;
	} else t21 = $[51];
	const headerConfig = t21;
	let t22;
	if ($[52] === Symbol.for("react.memo_cache_sentinel")) {
		t22 = [
			{ name: "agGridExport" },
			{ name: "agGridSizeColumnsToFit" },
			{ name: "agGridAutoSizeColumns" },
			{ name: "agGridResetColumns" },
			{ name: "agGridHideShowColumns" }
		];
		$[52] = t22;
	} else t22 = $[52];
	const gridFunctions = t22;
	let t23;
	if ($[53] === Symbol.for("react.memo_cache_sentinel")) {
		t23 = { pagination: true };
		$[53] = t23;
	} else t23 = $[53];
	const gridOptions = t23;
	let t24;
	if ($[54] === Symbol.for("react.memo_cache_sentinel")) {
		t24 = (api) => {
			transactionUiActionGridApiRef.current = api;
		};
		$[54] = t24;
	} else t24 = $[54];
	const handleGridApiCallback = t24;
	let t25;
	bb0: {
		let filterElements;
		if (transactionType?.transactionTypeId) {
			const t26 = transactionType?.transactionTypeId;
			let t27;
			if ($[55] !== t26) {
				t27 = [{
					searchField: "TransactionTypeId",
					searchOperator: "=",
					searchValue: t26,
					groupId: 1
				}];
				$[55] = t26;
				$[56] = t27;
			} else t27 = $[56];
			filterElements = t27;
			let t28;
			if ($[57] !== filterElements) {
				t28 = {
					requestUrl: `${ConfigService.productV1ApiUrl}/UdpTransactionUiAction/search`,
					customSearchObject: { filterElements }
				};
				$[57] = filterElements;
				$[58] = t28;
			} else t28 = $[58];
			t25 = t28;
			break bb0;
		}
		let t26;
		if ($[59] === Symbol.for("react.memo_cache_sentinel")) {
			t26 = {};
			$[59] = t26;
		} else t26 = $[59];
		t25 = t26;
	}
	const searchMethodConfig = t25;
	let t26;
	if ($[60] !== t) {
		t26 = t("Manage Form / Page Overrides");
		$[60] = t;
		$[61] = t26;
	} else t26 = $[61];
	let t27;
	if ($[62] !== handleTransactionUiActionSidesheet) {
		t27 = () => handleTransactionUiActionSidesheet(false);
		$[62] = handleTransactionUiActionSidesheet;
		$[63] = t27;
	} else t27 = $[63];
	let t28;
	if ($[64] !== columnDefs || $[65] !== headerConfig || $[66] !== searchMethodConfig) {
		t28 = /* @__PURE__ */ React.createElement(SearchMethodUdpGrid, {
			searchMethodConfig,
			columnDefs,
			gridHeaderConfig: headerConfig,
			gridOptions,
			gridApiCallback: handleGridApiCallback,
			gridFunctions
		});
		$[64] = columnDefs;
		$[65] = headerConfig;
		$[66] = searchMethodConfig;
		$[67] = t28;
	} else t28 = $[67];
	let t29;
	if ($[68] !== actionApis || $[69] !== handleCreateOrEditTransactionUiActionSidesheet || $[70] !== handleCreateTransactionUiAction || $[71] !== handleUpdateTransactionUiAction || $[72] !== isCreateOrEditTransactionUiActionSidesheetOpen || $[73] !== pages || $[74] !== tUiActionsList || $[75] !== transactionUiAction || $[76] !== transactionUiActionTypes) {
		t29 = /* @__PURE__ */ React.createElement(UdpTransactionUiActionCreateAndEditSidesheet, {
			initialTransactionUiAction: transactionUiAction,
			isSideSheetOpen: isCreateOrEditTransactionUiActionSidesheetOpen,
			handleCreateTransactionUiAction,
			handleUpdateTransactionUiAction,
			handleSideSheet: handleCreateOrEditTransactionUiActionSidesheet,
			transactionUiActionTypes,
			actionApis,
			pages,
			tUiActionsList
		});
		$[68] = actionApis;
		$[69] = handleCreateOrEditTransactionUiActionSidesheet;
		$[70] = handleCreateTransactionUiAction;
		$[71] = handleUpdateTransactionUiAction;
		$[72] = isCreateOrEditTransactionUiActionSidesheetOpen;
		$[73] = pages;
		$[74] = tUiActionsList;
		$[75] = transactionUiAction;
		$[76] = transactionUiActionTypes;
		$[77] = t29;
	} else t29 = $[77];
	let t30;
	if ($[78] !== isSideSheetOpen || $[79] !== t26 || $[80] !== t27 || $[81] !== t28 || $[82] !== t29) {
		t30 = /* @__PURE__ */ React.createElement(SideSheet, {
			open: isSideSheetOpen,
			width: 800,
			title: t26,
			onClose: t27
		}, t28, t29);
		$[78] = isSideSheetOpen;
		$[79] = t26;
		$[80] = t27;
		$[81] = t28;
		$[82] = t29;
		$[83] = t30;
	} else t30 = $[83];
	return t30;
};
var UdpTransactionUiActionSidesheet_default = forwardRef(UdpTransactionUiActionSidesheet);
function _temp(params_0) {
	return params_0.data;
}
//#endregion
export { UdpTransactionUiActionSidesheet_default as default };

//# sourceMappingURL=UdpTransactionUiActionSidesheet.mjs.map