import { ConfigService } from "../../configService/index.mjs";
import { useUser } from "../../utilities/auth/useUser.mjs";
import { LayoutUnit } from "../../layout/LayoutUnit.mjs";
import { useAxiosGet } from "../../utilities/useAxiosGet.mjs";
import { PageContainer } from "../../page/PageContainer/PageContainer.mjs";
import { VirtualForm } from "../../UI/forms/VirtualForm.mjs";
import { c } from "react-compiler-runtime";
import React from "react";
import { Divider, makeStyles } from "@material-ui/core";
import PropTypes from "prop-types";
import { Skeleton } from "@material-ui/lab";
import { DndProvider } from "react-dnd";
import { HTML5Backend } from "react-dnd-html5-backend";
//#region src/maintenanceEngine/virtualBrowser/VirtualTableSidePanel.jsx
const useStyles = makeStyles((theme) => ({
	root: {},
	divider: { marginTop: theme.spacing(2) }
}));
const FIELD_NUMBER = 10;
const VirtualTableSidePanel = (props) => {
	const $ = c(35);
	const { tableDescription, value, crudTableEditionData, closeSideSheet, onCreate, onUpdate, pageId, setSideSheetWidth, setSideSheetButtonLabel, setSideSheetOnSubmit, setSideSheetProps } = props;
	const user = useUser();
	const classes = useStyles();
	let t0;
	if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
		t0 = {};
		$[0] = t0;
	} else t0 = $[0];
	const [t1] = useAxiosGet(ConfigService.tenantV1ApiUrl, `page/${pageId}`, t0, !!!pageId, false);
	const { data: page, loading: loadingPage } = t1;
	let skeletonArr;
	if ($[1] !== classes) {
		skeletonArr = [];
		for (let i = 0; i < FIELD_NUMBER; i++) skeletonArr.push(/* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Skeleton, {
			key: i,
			variant: "rect",
			className: classes.skeleton
		}), /* @__PURE__ */ React.createElement(LayoutUnit, { unit: "xxs" })));
		$[1] = classes;
		$[2] = skeletonArr;
	} else skeletonArr = $[2];
	const skeleton = skeletonArr;
	let t2;
	if (page) {
		const t3 = page?.pageId;
		let t4;
		if ($[3] !== closeSideSheet || $[4] !== crudTableEditionData || $[5] !== onCreate || $[6] !== onUpdate || $[7] !== setSideSheetButtonLabel || $[8] !== setSideSheetOnSubmit || $[9] !== setSideSheetProps || $[10] !== setSideSheetWidth || $[11] !== t3) {
			t4 = {
				pageId: t3,
				nodeObj: crudTableEditionData,
				setSideSheetWidth,
				setSideSheetButtonLabel,
				setSideSheetOnSubmit,
				closeSideSheet,
				setSideSheetProps,
				onCreate,
				onUpdate
			};
			$[3] = closeSideSheet;
			$[4] = crudTableEditionData;
			$[5] = onCreate;
			$[6] = onUpdate;
			$[7] = setSideSheetButtonLabel;
			$[8] = setSideSheetOnSubmit;
			$[9] = setSideSheetProps;
			$[10] = setSideSheetWidth;
			$[11] = t3;
			$[12] = t4;
		} else t4 = $[12];
		let t5;
		if ($[13] !== page || $[14] !== pageId || $[15] !== t4 || $[16] !== user) {
			t5 = /* @__PURE__ */ React.createElement(DndProvider, { backend: HTML5Backend }, /* @__PURE__ */ React.createElement(PageContainer, {
				user,
				key: pageId,
				pageData: page,
				widgetParams: t4,
				disableMargins: true
			}));
			$[13] = page;
			$[14] = pageId;
			$[15] = t4;
			$[16] = user;
			$[17] = t5;
		} else t5 = $[17];
		t2 = t5;
	} else {
		let t3;
		if ($[18] !== closeSideSheet || $[19] !== onCreate || $[20] !== onUpdate || $[21] !== tableDescription || $[22] !== value) {
			t3 = /* @__PURE__ */ React.createElement(VirtualForm, {
				tableDescription,
				rowValue: value,
				closeSideSheet,
				onCreate,
				onUpdate
			});
			$[18] = closeSideSheet;
			$[19] = onCreate;
			$[20] = onUpdate;
			$[21] = tableDescription;
			$[22] = value;
			$[23] = t3;
		} else t3 = $[23];
		let t4;
		if ($[24] === Symbol.for("react.memo_cache_sentinel")) {
			t4 = /* @__PURE__ */ React.createElement(Divider, null);
			$[24] = t4;
		} else t4 = $[24];
		let t5;
		if ($[25] !== classes.divider) {
			t5 = /* @__PURE__ */ React.createElement("div", { className: classes.divider }, t4);
			$[25] = classes.divider;
			$[26] = t5;
		} else t5 = $[26];
		let t6;
		if ($[27] !== t3 || $[28] !== t5) {
			t6 = /* @__PURE__ */ React.createElement(React.Fragment, null, t3, t5);
			$[27] = t3;
			$[28] = t5;
			$[29] = t6;
		} else t6 = $[29];
		t2 = t6;
	}
	const sideSheetContent = t2;
	let t3;
	if ($[30] !== classes || $[31] !== loadingPage || $[32] !== sideSheetContent || $[33] !== skeleton) {
		t3 = /* @__PURE__ */ React.createElement("div", null, loadingPage ? /* @__PURE__ */ React.createElement(React.Fragment, null, skeleton.map(_temp), /* @__PURE__ */ React.createElement(LayoutUnit, { unit: "md" }), /* @__PURE__ */ React.createElement(Skeleton, {
			variant: "rect",
			className: classes.skeletonButton
		})) : sideSheetContent);
		$[30] = classes;
		$[31] = loadingPage;
		$[32] = sideSheetContent;
		$[33] = skeleton;
		$[34] = t3;
	} else t3 = $[34];
	return t3;
};
VirtualTableSidePanel.propTypes = {
	tableDescription: PropTypes.array,
	crudTableEditionData: PropTypes.array,
	closeSideSheet: PropTypes.func,
	onCreate: PropTypes.func,
	onUpdate: PropTypes.func
};
function _temp(sk) {
	return sk;
}
//#endregion
export { VirtualTableSidePanel };

//# sourceMappingURL=VirtualTableSidePanel.mjs.map