import { SideSheet } from "../../../../UI/surfaces/SideSheet.mjs";
import UdpTransactionTypeConfigurationForm_default from "../forms/UdpTransactionTypeConfigurationForm.mjs";
import { c } from "react-compiler-runtime";
import React, { useRef } from "react";
import { useTranslation } from "react-i18next";
//#region src/udp/pages/UdpTransactionTypesPage/sidesheets/UdpTransactionTypeConfigurationCreateAndEditSidesheet.jsx
const UdpTransactionTypeConfigurationCreateAndEditSidesheet = (props) => {
	const $ = c(25);
	const { initialTransactionTypeConfiguration, isSideSheetOpen, handleSideSheet, handleCreateTransactionTypeConfiguration, handleUpdateTransactionTypeConfiguration, transactionRuleTypes, catalogObjectProperties, ttstatuses, roles } = props;
	const isEditing = !!initialTransactionTypeConfiguration;
	const formRef = useRef();
	const { t } = useTranslation();
	let t0;
	if ($[0] !== handleCreateTransactionTypeConfiguration || $[1] !== handleUpdateTransactionTypeConfiguration) {
		t0 = async (values, initialData) => {
			if (initialData) await handleUpdateTransactionTypeConfiguration(values, initialData);
			else await handleCreateTransactionTypeConfiguration(values);
		};
		$[0] = handleCreateTransactionTypeConfiguration;
		$[1] = handleUpdateTransactionTypeConfiguration;
		$[2] = t0;
	} else t0 = $[2];
	const onSubmitForm = t0;
	let t1;
	if ($[3] !== isEditing || $[4] !== t) {
		t1 = isEditing ? t("Edit Rule") : t("Create Rule");
		$[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] !== catalogObjectProperties || $[13] !== initialTransactionTypeConfiguration || $[14] !== onSubmitForm || $[15] !== roles || $[16] !== transactionRuleTypes || $[17] !== ttstatuses) {
		t5 = /* @__PURE__ */ React.createElement(UdpTransactionTypeConfigurationForm_default, {
			ref: formRef,
			onSubmit: onSubmitForm,
			initialData: initialTransactionTypeConfiguration,
			transactionRuleTypes,
			catalogObjectProperties,
			transactionTypeStatusOptions: ttstatuses,
			roles
		});
		$[12] = catalogObjectProperties;
		$[13] = initialTransactionTypeConfiguration;
		$[14] = onSubmitForm;
		$[15] = roles;
		$[16] = transactionRuleTypes;
		$[17] = ttstatuses;
		$[18] = t5;
	} else t5 = $[18];
	let t6;
	if ($[19] !== isSideSheetOpen || $[20] !== t1 || $[21] !== t2 || $[22] !== t3 || $[23] !== t5) {
		t6 = /* @__PURE__ */ React.createElement(SideSheet, {
			open: isSideSheetOpen,
			width: 800,
			title: t1,
			onClose: t2,
			buttonLabel: t3,
			onSubmit: t4
		}, t5);
		$[19] = isSideSheetOpen;
		$[20] = t1;
		$[21] = t2;
		$[22] = t3;
		$[23] = t5;
		$[24] = t6;
	} else t6 = $[24];
	return t6;
};
//#endregion
export { UdpTransactionTypeConfigurationCreateAndEditSidesheet as default };

//# sourceMappingURL=UdpTransactionTypeConfigurationCreateAndEditSidesheet.mjs.map