import { Field } from "../utilities/form/Field.mjs";
import { findTermByType } from "../utilities/maintenanceEngine/CrudBrowserUtilities.mjs";
import { DateTimeField } from "../UI/inputs/datetimes/DateTimeField.mjs";
import { FluentToggle } from "../UI/inputs/toggle/FluentToggle.mjs";
import { PropertyTypeEnum } from "../enums/propertyTypeEnums.mjs";
import { toLowerFirstChar, toTitleCase } from "../utilities/input/StringUtilities.mjs";
import { c } from "react-compiler-runtime";
import React from "react";
import { FormControlLabel, TextField } from "@material-ui/core";
//#region src/hooks/virtualActions.jsx
function useVirtualActions() {
	const $ = c(1);
	const renderInputByFieldType = _temp;
	let t0;
	if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
		t0 = { renderInputByFieldType };
		$[0] = t0;
	} else t0 = $[0];
	return t0;
}
function _temp(formField, index, virtualTableFormData, classes) {
	const NUMBER_TYPE = [
		PropertyTypeEnum.Int,
		PropertyTypeEnum.Long,
		PropertyTypeEnum.Double
	];
	if (formField.type === "boolean" && virtualTableFormData[toLowerFirstChar(formField.name)] === "") virtualTableFormData[toLowerFirstChar(formField.name)] = false;
	const fieldType = formField.type?.toLowerCase();
	const fieldIsNumberType = NUMBER_TYPE.includes(fieldType);
	const DefaultTextField = /* @__PURE__ */ React.createElement(Field, {
		component: TextField,
		id: `${formField.name}${index}`,
		name: toLowerFirstChar(formField.name),
		label: toTitleCase(formField.name),
		initialValue: virtualTableFormData[toLowerFirstChar(formField.name)] || "",
		type: fieldIsNumberType && "number",
		fullWidth: true,
		variant: "outlined",
		size: "small",
		required: !formField?.nullable,
		margin: "dense",
		InputProps: { classes: {
			root: classes?.input,
			input: classes?.formTextInput
		} },
		InputLabelProps: { classes: { root: classes?.labelRoot } },
		disabled: formField?.disabled
	});
	const DefaultFluentToggle = /* @__PURE__ */ React.createElement(FormControlLabel, {
		control: /* @__PURE__ */ React.createElement(Field, {
			component: FluentToggle,
			type: "checkbox",
			id: `${formField.name}${index}`,
			name: toLowerFirstChar(formField.name),
			label: toTitleCase(formField.name),
			initialValue: typeof virtualTableFormData[toLowerFirstChar(formField.name)] === "boolean" ? virtualTableFormData[toLowerFirstChar(formField.name)] : virtualTableFormData[toLowerFirstChar(formField.name)] === "true" ? true : false,
			disabled: formField?.disabled,
			classes: { root: classes?.switchRoot },
			color: "secondary",
			inputProps: { "aria-label": "Active condition" }
		}),
		label: toTitleCase(formField.name),
		labelPlacement: "start",
		style: { marginLeft: 4 }
	});
	switch (fieldType.toLowerCase()) {
		case findTermByType(fieldType, "int"):
		case findTermByType(fieldType, "long"):
		case findTermByType(fieldType, "double"):
		case findTermByType(fieldType, "string"):
		case findTermByType(fieldType, "string uuid"): return DefaultTextField;
		case findTermByType(fieldType, "boolean"): return DefaultFluentToggle;
		case findTermByType(fieldType, "datetime"): return /* @__PURE__ */ React.createElement(Field, {
			disabled: formField?.disabled,
			component: DateTimeField,
			id: `${formField.name}${index}`,
			name: toLowerFirstChar(formField.name),
			label: toTitleCase(formField.name),
			initialValue: virtualTableFormData[toLowerFirstChar(formField.name)] ? new Date(virtualTableFormData[toLowerFirstChar(formField.name)]) : "",
			fullWidth: true,
			variant: "outlined",
			size: "small",
			required: !formField?.nullable,
			style: { marginTop: 8 }
		});
		default: return null;
	}
}
//#endregion
export { useVirtualActions };

//# sourceMappingURL=virtualActions.mjs.map