import { Form } from "../../utilities/form/Form.mjs";
import { Field } from "../../utilities/form/Field.mjs";
import { SubmitButton } from "../../utilities/form/SubmitButton.mjs";
import { FormButtons } from "../../utilities/form/FormButtons.mjs";
import { LayoutUnit } from "../../layout/LayoutUnit.mjs";
import { c } from "react-compiler-runtime";
import React from "react";
import { LinearProgress, Paper, TextField, Typography, makeStyles, useTheme } from "@material-ui/core";
//#region src/UI/forms/LoginForm.jsx
const useStyles = makeStyles((theme) => ({
	root: {
		display: "flex",
		justifyContent: "center",
		marginTop: theme.spacing(8)
	},
	loginWindow: {
		position: "relative",
		flex: 1,
		padding: theme.spacing(3),
		width: 390
	},
	underline: { "&::after": { borderColor: "black" } },
	label: { color: "black" },
	logo: { width: 150 },
	error: { color: theme.palette.error.main }
}));
const LoginForm = (props) => {
	const $ = c(43);
	const { onSubmit, logo, usernameLabel, passwordLabel, error, loading } = props;
	const classes = useStyles();
	const theme = useTheme();
	let t0;
	if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
		t0 = /* @__PURE__ */ React.createElement(Typography, {
			variant: "h5",
			gutterBottom: true
		}, "Login");
		$[0] = t0;
	} else t0 = $[0];
	let t1;
	if ($[1] !== classes.error || $[2] !== error) {
		t1 = error && /* @__PURE__ */ React.createElement(Typography, {
			variant: "body1",
			className: classes.error
		}, "Your username or password is invalid");
		$[1] = classes.error;
		$[2] = error;
		$[3] = t1;
	} else t1 = $[3];
	let t2;
	if ($[4] !== classes.underline) {
		t2 = { classes: { underline: classes.underline } };
		$[4] = classes.underline;
		$[5] = t2;
	} else t2 = $[5];
	let t3;
	if ($[6] !== theme.palette.grey[500]) {
		t3 = {
			focused: true,
			shrink: true,
			style: { color: theme.palette.grey[500] }
		};
		$[6] = theme.palette.grey[500];
		$[7] = t3;
	} else t3 = $[7];
	const t4 = usernameLabel || "Sign in name";
	let t5;
	if ($[8] !== t2 || $[9] !== t3 || $[10] !== t4) {
		t5 = /* @__PURE__ */ React.createElement(Field, {
			component: TextField,
			margin: "normal",
			type: "email",
			name: "username",
			InputProps: t2,
			InputLabelProps: t3,
			label: t4,
			fullWidth: true,
			size: "small",
			variant: "standard",
			validate: _temp
		});
		$[8] = t2;
		$[9] = t3;
		$[10] = t4;
		$[11] = t5;
	} else t5 = $[11];
	let t6;
	if ($[12] !== classes.underline) {
		t6 = { classes: { underline: classes.underline } };
		$[12] = classes.underline;
		$[13] = t6;
	} else t6 = $[13];
	let t7;
	if ($[14] !== theme.palette.grey[500]) {
		t7 = {
			focused: true,
			shrink: true,
			style: { color: theme.palette.grey[500] }
		};
		$[14] = theme.palette.grey[500];
		$[15] = t7;
	} else t7 = $[15];
	const t8 = passwordLabel || "Password";
	let t9;
	if ($[16] !== t6 || $[17] !== t7 || $[18] !== t8) {
		t9 = /* @__PURE__ */ React.createElement(Field, {
			component: TextField,
			margin: "normal",
			type: "password",
			name: "password",
			InputProps: t6,
			InputLabelProps: t7,
			label: t8,
			fullWidth: true,
			size: "small",
			variant: "standard",
			validate: _temp2
		});
		$[16] = t6;
		$[17] = t7;
		$[18] = t8;
		$[19] = t9;
	} else t9 = $[19];
	let t10;
	if ($[20] === Symbol.for("react.memo_cache_sentinel")) {
		t10 = {
			justifyContent: "flex-end",
			marginBottom: 0
		};
		$[20] = t10;
	} else t10 = $[20];
	let t11;
	if ($[21] !== theme.palette.grey[800]) {
		t11 = /* @__PURE__ */ React.createElement(FormButtons, { style: t10 }, /* @__PURE__ */ React.createElement(SubmitButton, {
			variant: "contained",
			disablePristine: false,
			style: {
				margin: 0,
				backgroundColor: theme.palette.grey[800],
				color: "#fff"
			}
		}, "Sign In"));
		$[21] = theme.palette.grey[800];
		$[22] = t11;
	} else t11 = $[22];
	let t12;
	if ($[23] !== classes.logo || $[24] !== logo) {
		t12 = logo && /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("img", {
			className: classes.logo,
			src: logo,
			alt: "Unity"
		}));
		$[23] = classes.logo;
		$[24] = logo;
		$[25] = t12;
	} else t12 = $[25];
	let t13;
	if ($[26] === Symbol.for("react.memo_cache_sentinel")) {
		t13 = /* @__PURE__ */ React.createElement(LayoutUnit, { unit: "xxs" });
		$[26] = t13;
	} else t13 = $[26];
	let t14;
	if ($[27] !== classes.loginWindow || $[28] !== t1 || $[29] !== t11 || $[30] !== t12 || $[31] !== t5 || $[32] !== t9) {
		t14 = /* @__PURE__ */ React.createElement(Paper, { className: classes.loginWindow }, t0, t1, t5, t9, t11, t12, t13);
		$[27] = classes.loginWindow;
		$[28] = t1;
		$[29] = t11;
		$[30] = t12;
		$[31] = t5;
		$[32] = t9;
		$[33] = t14;
	} else t14 = $[33];
	let t15;
	if ($[34] !== loading) {
		t15 = loading && /* @__PURE__ */ React.createElement(LinearProgress, null);
		$[34] = loading;
		$[35] = t15;
	} else t15 = $[35];
	let t16;
	if ($[36] !== onSubmit || $[37] !== t14 || $[38] !== t15) {
		t16 = /* @__PURE__ */ React.createElement(Form, { onSubmit }, t14, t15);
		$[36] = onSubmit;
		$[37] = t14;
		$[38] = t15;
		$[39] = t16;
	} else t16 = $[39];
	let t17;
	if ($[40] !== classes.root || $[41] !== t16) {
		t17 = /* @__PURE__ */ React.createElement("div", { className: classes.root }, t16);
		$[40] = classes.root;
		$[41] = t16;
		$[42] = t17;
	} else t17 = $[42];
	return t17;
};
function _temp(value) {
	if (!value?.length) return "Please enter your sign in name";
}
function _temp2(value_0) {
	if (!value_0?.length) return "Please enter your password";
}
//#endregion
export { LoginForm };

//# sourceMappingURL=LoginForm.mjs.map