import { ConfigService } from "../../../../configService/index.mjs";
import { UdpTransactionActionEnums } from "../../../../enums/unitySystemEnums.mjs";
import { SideSheet } from "../../../../UI/surfaces/SideSheet.mjs";
import { SearchMethodUdpGrid } from "../../../../UI/templates/newGrid/SearchMethodUdpGrid.mjs";
import UdpTransactionTypeTransactionActionCreateAndEditSidesheet from "./UdpTransactionTypeTransactionActionCreateAndEditSidesheet.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/UdpTransactionTypeTransactionActionSidesheet.jsx
const UdpTransactionTypeTransactionActionSidesheet = (props, ref) => {
	const $ = c(98);
	const { transactionType, transactionTypeTransactionAction, isSideSheetOpen, isTransactionTypeTransactionActionCreateOrEditSidesheetOpen, handleTransactionTypeTransactionActionSidesheet, handleCreateOrEditTransactionTypeTransactionActionSidesheet, handleCreateTransactionTypeTransactionAction, handleUpdateTransactionTypeTransactionAction, handleDeleteTransactionTypeTransactionAction, transactionActions, catalogObjectProperties, actionApis, pages, ttstatuses } = props;
	const transactionTypeTransactionActionGridApiRef = useRef(null);
	const { t } = useTranslation();
	let t0;
	bb0: {
		if (!transactionActions) {
			let t1;
			if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
				t1 = [];
				$[0] = t1;
			} else t1 = $[0];
			t0 = t1;
			break bb0;
		}
		let t1;
		if ($[1] !== transactionActions) {
			t1 = transactionActions.filter(_temp);
			$[1] = transactionActions;
			$[2] = t1;
		} else t1 = $[2];
		t0 = t1;
	}
	const filteredTransactionActions = t0;
	let t1;
	if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
		t1 = () => ({ refreshServerSide: () => {
			transactionTypeTransactionActionGridApiRef.current?.refreshServerSide();
		} });
		$[3] = t1;
	} else t1 = $[3];
	useImperativeHandle(ref, t1);
	let t2;
	if ($[4] !== transactionActions) {
		t2 = (transactionActionId) => {
			if (!transactionActions) return "";
			return transactionActions.find((transactionAction) => transactionAction.transactionActionId === transactionActionId)?.name || "";
		};
		$[4] = transactionActions;
		$[5] = t2;
	} else t2 = $[5];
	const getTransactionActionName = t2;
	let t3;
	if ($[6] !== t) {
		t3 = t("Name");
		$[6] = t;
		$[7] = t3;
	} else t3 = $[7];
	let t4;
	if ($[8] !== t3) {
		t4 = {
			headerName: t3,
			field: "name",
			resizable: true,
			sortable: false
		};
		$[8] = t3;
		$[9] = t4;
	} else t4 = $[9];
	let t5;
	if ($[10] !== t) {
		t5 = t("Description");
		$[10] = t;
		$[11] = t5;
	} else t5 = $[11];
	let t6;
	if ($[12] !== t5) {
		t6 = {
			headerName: t5,
			field: "description",
			resizable: true,
			sortable: false
		};
		$[12] = t5;
		$[13] = t6;
	} else t6 = $[13];
	let t7;
	if ($[14] !== t) {
		t7 = t("Icon");
		$[14] = t;
		$[15] = t7;
	} else t7 = $[15];
	let t8;
	if ($[16] !== t7) {
		t8 = {
			headerName: t7,
			field: "icon",
			resizable: true,
			sortable: false
		};
		$[16] = t7;
		$[17] = t8;
	} else t8 = $[17];
	let t9;
	if ($[18] !== t) {
		t9 = t("Transaction Action");
		$[18] = t;
		$[19] = t9;
	} else t9 = $[19];
	let t10;
	if ($[20] !== getTransactionActionName) {
		t10 = (params) => getTransactionActionName(params.data.transactionActionId);
		$[20] = getTransactionActionName;
		$[21] = t10;
	} else t10 = $[21];
	let t11;
	if ($[22] !== t10 || $[23] !== t9) {
		t11 = {
			headerName: t9,
			resizable: true,
			sortable: false,
			valueGetter: t10
		};
		$[22] = t10;
		$[23] = t9;
		$[24] = t11;
	} else t11 = $[24];
	let t12;
	if ($[25] !== t) {
		t12 = t("Actions");
		$[25] = t;
		$[26] = t12;
	} else t12 = $[26];
	let t13;
	if ($[27] !== t) {
		t13 = t("Edit");
		$[27] = t;
		$[28] = t13;
	} else t13 = $[28];
	let t14;
	if ($[29] !== handleCreateOrEditTransactionTypeTransactionActionSidesheet) {
		t14 = (e, transactionTypeTransactionAction_0) => {
			handleCreateOrEditTransactionTypeTransactionActionSidesheet(true, transactionTypeTransactionAction_0?.data);
		};
		$[29] = handleCreateOrEditTransactionTypeTransactionActionSidesheet;
		$[30] = t14;
	} else t14 = $[30];
	let t15;
	if ($[31] !== t13 || $[32] !== t14) {
		t15 = {
			id: 0,
			title: t13,
			iconName: "edit",
			handleOnClick: t14
		};
		$[31] = t13;
		$[32] = t14;
		$[33] = t15;
	} else t15 = $[33];
	let t16;
	if ($[34] !== t) {
		t16 = t("Delete");
		$[34] = t;
		$[35] = t16;
	} else t16 = $[35];
	let t17;
	if ($[36] !== handleDeleteTransactionTypeTransactionAction) {
		t17 = (e_0, transactionTypeTransactionAction_1) => {
			handleDeleteTransactionTypeTransactionAction(transactionTypeTransactionAction_1?.data);
		};
		$[36] = handleDeleteTransactionTypeTransactionAction;
		$[37] = t17;
	} else t17 = $[37];
	let t18;
	if ($[38] !== t16 || $[39] !== t17) {
		t18 = {
			id: 1,
			title: t16,
			iconName: "trashCan",
			handleOnClick: t17
		};
		$[38] = t16;
		$[39] = t17;
		$[40] = t18;
	} else t18 = $[40];
	let t19;
	if ($[41] !== t15 || $[42] !== t18) {
		t19 = { actionList: [t15, t18] };
		$[41] = t15;
		$[42] = t18;
		$[43] = t19;
	} else t19 = $[43];
	let t20;
	if ($[44] !== t12 || $[45] !== t19) {
		t20 = {
			headerName: t12,
			field: "actions",
			cellRenderer: "actionsRenderer",
			cellRendererParams: t19,
			suppressMenu: true,
			sortable: false,
			filter: false,
			valueGetter: _temp2
		};
		$[44] = t12;
		$[45] = t19;
		$[46] = t20;
	} else t20 = $[46];
	let t21;
	if ($[47] !== t11 || $[48] !== t20 || $[49] !== t4 || $[50] !== t6 || $[51] !== t8) {
		t21 = [
			t4,
			t6,
			t8,
			t11,
			t20
		];
		$[47] = t11;
		$[48] = t20;
		$[49] = t4;
		$[50] = t6;
		$[51] = t8;
		$[52] = t21;
	} else t21 = $[52];
	const columnDefs = t21;
	let t22;
	if ($[53] !== t) {
		t22 = t("Actions");
		$[53] = t;
		$[54] = t22;
	} else t22 = $[54];
	let t23;
	if ($[55] !== t) {
		t23 = t("Add");
		$[55] = t;
		$[56] = t23;
	} else t23 = $[56];
	let t24;
	if ($[57] !== handleCreateOrEditTransactionTypeTransactionActionSidesheet) {
		t24 = () => handleCreateOrEditTransactionTypeTransactionActionSidesheet(true);
		$[57] = handleCreateOrEditTransactionTypeTransactionActionSidesheet;
		$[58] = t24;
	} else t24 = $[58];
	let t25;
	if ($[59] !== t23 || $[60] !== t24) {
		t25 = {
			label: t23,
			iconName: "add",
			onClick: t24
		};
		$[59] = t23;
		$[60] = t24;
		$[61] = t25;
	} else t25 = $[61];
	let t26;
	if ($[62] !== t22 || $[63] !== t25) {
		t26 = {
			title: t22,
			primaryActionButton: t25
		};
		$[62] = t22;
		$[63] = t25;
		$[64] = t26;
	} else t26 = $[64];
	const headerConfig = t26;
	let t27;
	if ($[65] === Symbol.for("react.memo_cache_sentinel")) {
		t27 = [
			{ name: "agGridExport" },
			{ name: "agGridSizeColumnsToFit" },
			{ name: "agGridAutoSizeColumns" },
			{ name: "agGridResetColumns" },
			{ name: "agGridHideShowColumns" }
		];
		$[65] = t27;
	} else t27 = $[65];
	const gridFunctions = t27;
	let t28;
	if ($[66] === Symbol.for("react.memo_cache_sentinel")) {
		t28 = { pagination: true };
		$[66] = t28;
	} else t28 = $[66];
	const gridOptions = t28;
	let t29;
	if ($[67] === Symbol.for("react.memo_cache_sentinel")) {
		t29 = (api) => {
			transactionTypeTransactionActionGridApiRef.current = api;
		};
		$[67] = t29;
	} else t29 = $[67];
	const handleGridApiCallback = t29;
	let t30;
	bb1: {
		let filterElements;
		if (transactionType?.transactionTypeId) {
			const t31 = transactionType?.transactionTypeId;
			let t32;
			if ($[68] !== t31) {
				t32 = [{
					searchField: "TransactionTypeId",
					searchOperator: "=",
					searchValue: t31,
					groupId: 1
				}];
				$[68] = t31;
				$[69] = t32;
			} else t32 = $[69];
			filterElements = t32;
			let t33;
			if ($[70] !== filterElements) {
				t33 = {
					requestUrl: `${ConfigService.productV1ApiUrl}/UdpTransactionTypeTransactionAction/search`,
					customSearchObject: { filterElements }
				};
				$[70] = filterElements;
				$[71] = t33;
			} else t33 = $[71];
			t30 = t33;
			break bb1;
		}
		let t31;
		if ($[72] === Symbol.for("react.memo_cache_sentinel")) {
			t31 = {};
			$[72] = t31;
		} else t31 = $[72];
		t30 = t31;
	}
	const searchMethodConfig = t30;
	let t31;
	if ($[73] !== t) {
		t31 = t("Manage Actions");
		$[73] = t;
		$[74] = t31;
	} else t31 = $[74];
	let t32;
	if ($[75] !== handleTransactionTypeTransactionActionSidesheet) {
		t32 = () => handleTransactionTypeTransactionActionSidesheet(false);
		$[75] = handleTransactionTypeTransactionActionSidesheet;
		$[76] = t32;
	} else t32 = $[76];
	let t33;
	if ($[77] !== columnDefs || $[78] !== headerConfig || $[79] !== searchMethodConfig) {
		t33 = /* @__PURE__ */ React.createElement(SearchMethodUdpGrid, {
			searchMethodConfig,
			columnDefs,
			gridHeaderConfig: headerConfig,
			gridOptions,
			gridApiCallback: handleGridApiCallback,
			gridFunctions
		});
		$[77] = columnDefs;
		$[78] = headerConfig;
		$[79] = searchMethodConfig;
		$[80] = t33;
	} else t33 = $[80];
	let t34;
	if ($[81] !== actionApis || $[82] !== catalogObjectProperties || $[83] !== filteredTransactionActions || $[84] !== handleCreateOrEditTransactionTypeTransactionActionSidesheet || $[85] !== handleCreateTransactionTypeTransactionAction || $[86] !== handleUpdateTransactionTypeTransactionAction || $[87] !== isTransactionTypeTransactionActionCreateOrEditSidesheetOpen || $[88] !== pages || $[89] !== transactionTypeTransactionAction || $[90] !== ttstatuses) {
		t34 = /* @__PURE__ */ React.createElement(UdpTransactionTypeTransactionActionCreateAndEditSidesheet, {
			initialTransactionTypeTransactionAction: transactionTypeTransactionAction,
			isSideSheetOpen: isTransactionTypeTransactionActionCreateOrEditSidesheetOpen,
			handleCreateTransactionTypeTransactionAction,
			handleUpdateTransactionTypeTransactionAction,
			handleSideSheet: handleCreateOrEditTransactionTypeTransactionActionSidesheet,
			transactionActions: filteredTransactionActions,
			catalogObjectProperties,
			actionApis,
			pages,
			transactionTypeStatusOptions: ttstatuses
		});
		$[81] = actionApis;
		$[82] = catalogObjectProperties;
		$[83] = filteredTransactionActions;
		$[84] = handleCreateOrEditTransactionTypeTransactionActionSidesheet;
		$[85] = handleCreateTransactionTypeTransactionAction;
		$[86] = handleUpdateTransactionTypeTransactionAction;
		$[87] = isTransactionTypeTransactionActionCreateOrEditSidesheetOpen;
		$[88] = pages;
		$[89] = transactionTypeTransactionAction;
		$[90] = ttstatuses;
		$[91] = t34;
	} else t34 = $[91];
	let t35;
	if ($[92] !== isSideSheetOpen || $[93] !== t31 || $[94] !== t32 || $[95] !== t33 || $[96] !== t34) {
		t35 = /* @__PURE__ */ React.createElement(SideSheet, {
			open: isSideSheetOpen,
			width: 800,
			title: t31,
			onClose: t32
		}, t33, t34);
		$[92] = isSideSheetOpen;
		$[93] = t31;
		$[94] = t32;
		$[95] = t33;
		$[96] = t34;
		$[97] = t35;
	} else t35 = $[97];
	return t35;
};
var UdpTransactionTypeTransactionActionSidesheet_default = forwardRef(UdpTransactionTypeTransactionActionSidesheet);
function _temp(ta) {
	return ta?.name !== UdpTransactionActionEnums.Send_Email && ta?.name !== UdpTransactionActionEnums.Custom_Client_Action;
}
function _temp2(params_0) {
	return params_0.data;
}
//#endregion
export { UdpTransactionTypeTransactionActionSidesheet_default as default };

//# sourceMappingURL=UdpTransactionTypeTransactionActionSidesheet.mjs.map