import { Form } from "../../../../utilities/form/Form.mjs";
import { Field } from "../../../../utilities/form/Field.mjs";
import { AmbientAutoComplete } from "../../../../UI/inputs/textField/AmbientAutoComplete.mjs";
import { c } from "react-compiler-runtime";
import React, { forwardRef, useImperativeHandle, useRef } from "react";
import { useTranslation } from "react-i18next";
//#region src/udp/pages/UdpTransactionTypesPage/forms/UdpTransactionUiActionForm.jsx
const UdpTransactionUiActionForm = (props, ref) => {
	const $ = c(15);
	const { onSubmit, initialData, transactionUiActionTypeOptions, actionApiOptions, pageOptions } = props;
	const { t } = useTranslation();
	const handleSubmitRef = useRef();
	let t0;
	if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
		t0 = () => ({ submit: () => {
			handleSubmitRef?.current();
		} });
		$[0] = t0;
	} else t0 = $[0];
	useImperativeHandle(ref, t0);
	let t1;
	if ($[1] !== initialData || $[2] !== onSubmit) {
		t1 = (formData) => {
			onSubmit(formData, initialData);
		};
		$[1] = initialData;
		$[2] = onSubmit;
		$[3] = t1;
	} else t1 = $[3];
	const handleSubmit = t1;
	let t2;
	if ($[4] !== actionApiOptions || $[5] !== initialData?.parameters?.actionApiId || $[6] !== initialData?.parameters?.pageId || $[7] !== initialData?.transactionUiActionTypeId || $[8] !== pageOptions || $[9] !== t || $[10] !== transactionUiActionTypeOptions) {
		t2 = (t3) => {
			const { handleSubmit: handleSubmit_0 } = t3;
			handleSubmitRef.current = handleSubmit_0;
			return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Field, {
				component: AmbientAutoComplete,
				label: t("Transaction UI Action Type"),
				id: "transactionUiActionType",
				name: "transactionUiActionType",
				variant: "outlined",
				isMultiple: false,
				disableCloseOnSelect: false,
				options: transactionUiActionTypeOptions || [],
				getOptionLabelFunction: _temp,
				initialValue: transactionUiActionTypeOptions?.find((transactionUiActionType) => transactionUiActionType?.transactionUiActionTypeId === initialData?.transactionUiActionTypeId) || null,
				required: true
			}), /* @__PURE__ */ React.createElement(Field, {
				component: AmbientAutoComplete,
				label: t("Action Api"),
				id: "actionApi",
				name: "actionApi",
				variant: "outlined",
				isMultiple: false,
				disableCloseOnSelect: false,
				options: actionApiOptions || [],
				getOptionLabelFunction: _temp2,
				initialValue: actionApiOptions?.find((actionApi) => actionApi?.actionApiId === initialData?.parameters?.actionApiId) || null
			}), /* @__PURE__ */ React.createElement(Field, {
				component: AmbientAutoComplete,
				label: t("Page"),
				id: "page",
				name: "page",
				variant: "outlined",
				isMultiple: false,
				disableCloseOnSelect: false,
				options: pageOptions || [],
				getOptionLabelFunction: _temp3,
				initialValue: pageOptions?.find((page) => page?.pageId === initialData?.parameters?.pageId) || null
			}));
		};
		$[4] = actionApiOptions;
		$[5] = initialData?.parameters?.actionApiId;
		$[6] = initialData?.parameters?.pageId;
		$[7] = initialData?.transactionUiActionTypeId;
		$[8] = pageOptions;
		$[9] = t;
		$[10] = transactionUiActionTypeOptions;
		$[11] = t2;
	} else t2 = $[11];
	let t3;
	if ($[12] !== handleSubmit || $[13] !== t2) {
		t3 = /* @__PURE__ */ React.createElement(Form, {
			onSubmit: handleSubmit,
			render: t2
		});
		$[12] = handleSubmit;
		$[13] = t2;
		$[14] = t3;
	} else t3 = $[14];
	return t3;
};
var UdpTransactionUiActionForm_default = forwardRef(UdpTransactionUiActionForm);
function _temp(option) {
	return option.name;
}
function _temp2(option_0) {
	return option_0.name;
}
function _temp3(option_1) {
	return option_1.name;
}
//#endregion
export { UdpTransactionUiActionForm_default as default };

//# sourceMappingURL=UdpTransactionUiActionForm.mjs.map