import { useStudio as e } from "../providers/StudioProvider.js";
import { useChildWorkflows as t, useWorkflow as n, useWorkflowConfigByName as r } from "../hooks/useWorkflows.js";
import { useWorkspace as i } from "../hooks/useWorkspaces.js";
import a from "../components/layout/MainLayout.js";
import o from "../components/feedback/ErrorSnackbar.js";
import { ReactFlowProvider as s } from "../node_modules/@xyflow/react/dist/esm/index.js";
import c from "../features/debug/components/WorkflowFlowViewer.js";
import l from "../features/debug/components/WorkflowDebugHeader.js";
import "../features/debug/index.js";
import { requireParam as u } from "../lib/requireParam.js";
import { useMemo as d } from "react";
import { jsx as f, jsxs as p } from "react/jsx-runtime";
import { useParams as m } from "react-router-dom";
import { Bug as h, Home as g, Loader2 as _ } from "lucide-react";
//#region src/pages/WorkflowDebugPage.tsx
var v = () => {
	let { router: v } = e(), y = u(m(), "workflowId"), b = n(y), x = b.data?.workspaceId, S = i(x), C = t(y), w = d(() => C.data ?? [], [C.data]), T = r(b.data?.className ?? void 0), E = d(() => [
		{
			label: "Dashboard",
			href: v.getDashboard(),
			icon: /* @__PURE__ */ f(g, { className: "h-4 w-4" })
		},
		{
			label: "Workspaces",
			href: v.getWorkspaces()
		},
		{
			label: S.data?.title ?? "...",
			href: x ? v.getWorkspace(x) : void 0
		},
		{
			label: `Run #${b.data?.run ?? "..."}`,
			href: v.getWorkflow(y)
		},
		{
			label: "Debug Flow",
			icon: /* @__PURE__ */ f(h, { className: "h-4 w-4" })
		}
	], [
		S.data,
		b.data,
		x,
		y,
		v
	]);
	return b.isLoading || C.isLoading || S.isLoading ? /* @__PURE__ */ f(a, {
		breadcrumbsData: E,
		children: /* @__PURE__ */ f("div", {
			className: "flex h-[calc(100vh-8rem)] items-center justify-center",
			children: /* @__PURE__ */ f(_, { className: "text-muted-foreground h-8 w-8 animate-spin" })
		})
	}) : /* @__PURE__ */ p(a, {
		breadcrumbsData: E,
		children: [/* @__PURE__ */ f(o, { error: b.error }), /* @__PURE__ */ p("div", {
			className: "flex h-[calc(100vh-8rem)] flex-col gap-6",
			children: [/* @__PURE__ */ f(l, {
				title: b.data?.title ?? b.data?.alias ?? "Workflow",
				runNumber: b.data?.run,
				onBack: () => void v.navigateToWorkflow(y)
			}), /* @__PURE__ */ f("div", {
				className: "bg-card border-border flex-1 overflow-hidden rounded-2xl border shadow-sm",
				children: w.length > 0 ? /* @__PURE__ */ f(s, { children: /* @__PURE__ */ f(c, {
					workflowId: y,
					workflows: w,
					workflowConfig: T.data
				}) }) : /* @__PURE__ */ f("div", {
					className: "text-muted-foreground flex h-full items-center justify-center",
					children: /* @__PURE__ */ f("p", {
						className: "font-medium",
						children: "No child workflows found for this workflow"
					})
				})
			})]
		})]
	});
};
//#endregion
export { v as default };
