import { useStudio } from "../providers/StudioProvider.js";
import MainLayout_default from "../components/layout/MainLayout.js";
import { usePipelineConfig, usePipelineSource } from "../hooks/usePipelines.js";
import { ReactFlowProvider } from "../node_modules/@xyflow/react/dist/esm/index.js";
import ConfigFlowViewer_default from "../features/debug/components/ConfigFlowViewer.js";
import { c } from "react/compiler-runtime";
import { useMemo } from "react";
import { jsx, jsxs } from "react/jsx-runtime";
import { useParams } from "react-router-dom";
import { Home, Loader2 } from "lucide-react";
import { Prism } from "react-syntax-highlighter";
import { vscDarkPlus } from "react-syntax-highlighter/dist/esm/styles/prism";
function DebugWorkflowDetailsPage() {
	let h = c(29), { workflowId: g } = useParams(), { router: _ } = useStudio(), v;
	bb0: {
		if (!g) {
			let t;
			h[0] === Symbol.for("react.memo_cache_sentinel") ? (t = ["", ""], h[0] = t) : t = h[0], v = t;
			break bb0;
		}
		let t;
		h[1] === g ? t = h[2] : (t = g.split("::"), h[1] = g, h[2] = t);
		let p = t;
		if (p.length === 2) {
			v = p;
			break bb0;
		}
		let m;
		h[3] === g ? m = h[4] : (m = ["default", g], h[3] = g, h[4] = m), v = m;
	}
	let [y, b] = v, { data: x, isLoading: S } = usePipelineConfig(y, b), { data: C, isLoading: w } = usePipelineSource(y, b), T = S || w, E;
	h[5] === _ ? E = h[6] : (E = _.getDashboard(), h[5] = _, h[6] = E);
	let D;
	h[7] === Symbol.for("react.memo_cache_sentinel") ? (D = /* @__PURE__ */ jsx(Home, { className: "h-4 w-4" }), h[7] = D) : D = h[7];
	let O;
	h[8] === E ? O = h[9] : (O = {
		label: "Dashboard",
		href: E,
		icon: D
	}, h[8] = E, h[9] = O);
	let k;
	h[10] === _ ? k = h[11] : (k = _.getDebugWorkflows(), h[10] = _, h[11] = k);
	let A;
	h[12] === k ? A = h[13] : (A = {
		label: "Debug Workflows",
		href: k
	}, h[12] = k, h[13] = A);
	let j = x?.title || x?.blockName || b || "Workflow Details", M;
	h[14] === j ? M = h[15] : (M = {
		label: j,
		current: !0
	}, h[14] = j, h[15] = M);
	let N;
	h[16] !== O || h[17] !== A || h[18] !== M ? (N = [
		O,
		A,
		M
	], h[16] = O, h[17] = A, h[18] = M, h[19] = N) : N = h[19];
	let P = N, F;
	h[20] !== T || h[21] !== b || h[22] !== C || h[23] !== x || h[24] !== y ? (F = T ? /* @__PURE__ */ jsxs("div", {
		className: "flex items-center space-x-2",
		children: [/* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin" }), /* @__PURE__ */ jsx("span", { children: "Loading..." })]
	}) : x ? /* @__PURE__ */ jsxs("div", {
		className: "flex h-[calc(100vh-8rem)] flex-col gap-4",
		children: [
			/* @__PURE__ */ jsx("h1", {
				className: "text-3xl font-bold tracking-tight",
				children: x.title || x.blockName
			}),
			/* @__PURE__ */ jsx("p", {
				className: "text-muted-foreground",
				children: x.description
			}),
			/* @__PURE__ */ jsxs("div", {
				className: "flex flex-1 gap-4 overflow-hidden",
				children: [/* @__PURE__ */ jsxs("div", {
					className: "w-1/2 flex flex-col rounded-lg border bg-card text-card-foreground shadow-sm overflow-hidden",
					children: [/* @__PURE__ */ jsx("div", {
						className: "border-b bg-muted/50 px-4 py-2 font-medium text-sm",
						children: C?.filePath
					}), /* @__PURE__ */ jsx("div", {
						className: "flex-1 overflow-auto bg-[#1e1e1e]",
						children: /* @__PURE__ */ jsx(Prism, {
							language: C?.raw ? "yaml" : "json",
							style: vscDarkPlus,
							customStyle: {
								margin: 0,
								padding: "1rem",
								height: "100%",
								fontSize: "13px"
							},
							showLineNumbers: !0,
							children: C?.raw ? C.raw : JSON.stringify(x, null, 2)
						})
					})]
				}), /* @__PURE__ */ jsxs("div", {
					className: "w-1/2 flex flex-col rounded-lg border bg-card text-card-foreground shadow-sm overflow-hidden",
					children: [/* @__PURE__ */ jsx("div", {
						className: "border-b bg-muted/50 px-4 py-2 font-medium text-sm",
						children: "Diagram"
					}), /* @__PURE__ */ jsx("div", {
						className: "flex-1 relative bg-background",
						children: /* @__PURE__ */ jsx(ReactFlowProvider, { children: /* @__PURE__ */ jsx(ConfigFlowViewer_default, { config: x }) })
					})]
				})]
			})
		]
	}) : /* @__PURE__ */ jsxs("div", { children: [
		"Workflow Type not found (Workspace: ",
		y,
		", Pipeline: ",
		b,
		")"
	] }), h[20] = T, h[21] = b, h[22] = C, h[23] = x, h[24] = y, h[25] = F) : F = h[25];
	let I;
	return h[26] !== P || h[27] !== F ? (I = /* @__PURE__ */ jsx(MainLayout_default, {
		breadcrumbsData: P,
		children: F
	}), h[26] = P, h[27] = F, h[28] = I) : I = h[28], I;
}
export { DebugWorkflowDetailsPage as default };
