import { cn as e } from "../../lib/utils.js";
import t from "../../components/feedback/LoadingCentered.js";
import n from "../../components/feedback/ErrorSnackbar.js";
import r from "../../components/feedback/ErrorAlert.js";
import i from "../documents/components/DocumentList.js";
import "../documents/index.js";
import a from "./components/WorkflowForms.js";
import { useWorkflowData as o } from "./hooks/useWorkflowData.js";
import { useEffect as s } from "react";
import { jsx as c, jsxs as l } from "react/jsx-runtime";
import { useParams as u } from "react-router-dom";
//#region src/features/workbench/WorkflowItem.tsx
var d = ({ workflow: d, workflowId: f, scrollTo: p, settings: m, embed: h }) => {
	let { workflowId: g, clickId: _ } = u(), { workflow: v, workflowLoading: y, workflowReady: b, workflowError: x, documents: S, documentsLoading: C, documentsReady: w, documentsError: T, isLoading: E, handleRun: D } = o({
		workflowId: f,
		showFullMessageHistory: m.showFullMessageHistory
	});
	return s(() => {
		g === f && b && w && p(f);
	}, [
		b,
		w,
		f,
		g,
		_,
		p
	]), /* @__PURE__ */ l("div", {
		className: e("flex flex-col", h ? "p-0" : "p-4"),
		children: [
			/* @__PURE__ */ c(t, { loading: y || C }),
			/* @__PURE__ */ c(n, { error: T }),
			/* @__PURE__ */ c(r, { error: x }),
			b && v && /* @__PURE__ */ c(i, {
				workflow: d,
				childWorkflow: v,
				documents: S,
				scrollTo: p,
				settings: m,
				isLoading: E
			}),
			/* @__PURE__ */ c(t, { loading: E }),
			!!v && /* @__PURE__ */ c("div", {
				className: "mt-6",
				children: /* @__PURE__ */ c(a, {
					workflow: v,
					parentWorkflow: d,
					onSubmit: D
				})
			})
		]
	});
};
//#endregion
export { d as default };
