import { SideSheet } from "../../../../UI/surfaces/SideSheet.mjs";
import UdpTransactionTypeTransactionActionForm_default from "../forms/UdpTransactionTypeTransactionActionForm.mjs";
import { c } from "react-compiler-runtime";
import React, { useRef } from "react";
import { useTranslation } from "react-i18next";
//#region src/udp/pages/UdpTransactionTypesPage/sidesheets/UdpTransactionTypeTransactionActionCreateAndEditSidesheet.jsx
const UdpTransactionTypeTransactionActionCreateAndEditSidesheet = (props) => {
	const $ = c(26);
	const { initialTransactionTypeTransactionAction, isSideSheetOpen, handleSideSheet, handleCreateTransactionTypeTransactionAction, handleUpdateTransactionTypeTransactionAction, transactionActions, catalogObjectProperties, actionApis, pages, transactionTypeStatusOptions } = props;
	const isEditing = !!initialTransactionTypeTransactionAction;
	const formRef = useRef();
	const { t } = useTranslation();
	let t0;
	if ($[0] !== handleCreateTransactionTypeTransactionAction || $[1] !== handleUpdateTransactionTypeTransactionAction) {
		t0 = async (values, initialData) => {
			if (initialData) await handleUpdateTransactionTypeTransactionAction(values, initialData);
			else await handleCreateTransactionTypeTransactionAction(values);
		};
		$[0] = handleCreateTransactionTypeTransactionAction;
		$[1] = handleUpdateTransactionTypeTransactionAction;
		$[2] = t0;
	} else t0 = $[2];
	const onSubmitForm = t0;
	let t1;
	if ($[3] !== isEditing || $[4] !== t) {
		t1 = isEditing ? t("Edit Action") : t("Create Action");
		$[3] = isEditing;
		$[4] = t;
		$[5] = t1;
	} else t1 = $[5];
	let t2;
	if ($[6] !== handleSideSheet) {
		t2 = () => handleSideSheet(false);
		$[6] = handleSideSheet;
		$[7] = t2;
	} else t2 = $[7];
	let t3;
	if ($[8] !== isEditing || $[9] !== t) {
		t3 = isEditing ? t("Save") : t("Create");
		$[8] = isEditing;
		$[9] = t;
		$[10] = t3;
	} else t3 = $[10];
	let t4;
	if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
		t4 = () => {
			formRef?.current?.submit();
		};
		$[11] = t4;
	} else t4 = $[11];
	let t5;
	if ($[12] !== actionApis || $[13] !== catalogObjectProperties || $[14] !== initialTransactionTypeTransactionAction || $[15] !== onSubmitForm || $[16] !== pages || $[17] !== transactionActions || $[18] !== transactionTypeStatusOptions) {
		t5 = /* @__PURE__ */ React.createElement(UdpTransactionTypeTransactionActionForm_default, {
			ref: formRef,
			onSubmit: onSubmitForm,
			initialData: initialTransactionTypeTransactionAction,
			transactionActionOptions: transactionActions,
			catalogObjectProperties,
			actionApiOptions: actionApis,
			pageOptions: pages,
			transactionTypeStatusOptions
		});
		$[12] = actionApis;
		$[13] = catalogObjectProperties;
		$[14] = initialTransactionTypeTransactionAction;
		$[15] = onSubmitForm;
		$[16] = pages;
		$[17] = transactionActions;
		$[18] = transactionTypeStatusOptions;
		$[19] = t5;
	} else t5 = $[19];
	let t6;
	if ($[20] !== isSideSheetOpen || $[21] !== t1 || $[22] !== t2 || $[23] !== t3 || $[24] !== t5) {
		t6 = /* @__PURE__ */ React.createElement(SideSheet, {
			open: isSideSheetOpen,
			width: 600,
			title: t1,
			onClose: t2,
			buttonLabel: t3,
			onSubmit: t4
		}, t5);
		$[20] = isSideSheetOpen;
		$[21] = t1;
		$[22] = t2;
		$[23] = t3;
		$[24] = t5;
		$[25] = t6;
	} else t6 = $[25];
	return t6;
};
//#endregion
export { UdpTransactionTypeTransactionActionCreateAndEditSidesheet as default };

//# sourceMappingURL=UdpTransactionTypeTransactionActionCreateAndEditSidesheet.mjs.map