import { useStudio } from "../../../providers/StudioProvider.js";
import { Button } from "../../../components/ui/button.js";
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "../../../components/ui/tooltip.js";
import { Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupLabel, SidebarHeader, SidebarMenu, SidebarTrigger, useSidebar } from "../../../components/ui/sidebar.js";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "../../../components/ui/tabs.js";
import { CodeExplorer } from "../../code-explorer/CodeExplorer.js";
import WorkbenchNavigation_default from "../WorkbenchNavigation.js";
import PipelineHistoryList_default from "./PipelineHistoryList.js";
import { c } from "react/compiler-runtime";
import { jsx, jsxs } from "react/jsx-runtime";
import { Code, GitGraph } from "lucide-react";
var WorkbenchSidebar_default = (O) => {
	let k = c(30), { namespaceTree: A, pipeline: j, workspaceConfig: M } = O, { router: N } = useStudio(), { open: P } = useSidebar(), F = M?.features, I = F?.sidebar?.enabled ?? !0, L = F?.debugWorkflow?.enabled ?? !0, R = F?.fileExplorer?.enabled ?? !1, z = F?.workflowNavigation?.enabled ?? !0, B = F?.workflowHistory?.enabled ?? !0;
	if (!I) return null;
	let V;
	k[0] !== R || k[1] !== B || k[2] !== z ? (V = () => R ? "codeExplorer" : z ? "pipelineNavigation" : B ? "pipelineHistory" : "codeExplorer", k[0] = R, k[1] = B, k[2] = z, k[3] = V) : V = k[3];
	let H = V, U;
	k[4] !== R || k[5] !== B || k[6] !== z ? (U = [
		R,
		z,
		B
	].filter(Boolean), k[4] = R, k[5] = B, k[6] = z, k[7] = U) : U = k[7];
	let W = U.length, G;
	k[8] === Symbol.for("react.memo_cache_sentinel") ? (G = /* @__PURE__ */ jsx(SidebarTrigger, { className: "flex h-8 w-8 items-center justify-center hover:cursor-pointer" }), k[8] = G) : G = k[8];
	let K;
	k[9] !== L || k[10] !== j || k[11] !== N ? (K = j && L && /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, {
		asChild: !0,
		children: /* @__PURE__ */ jsx(Button, {
			variant: "ghost",
			size: "icon",
			className: "h-8 w-8",
			onClick: () => void N.navigateToPipelineDebug(j.id),
			children: /* @__PURE__ */ jsx(GitGraph, { className: "text-muted-foreground h-4 w-4" })
		})
	}), /* @__PURE__ */ jsx(TooltipContent, {
		side: "bottom",
		children: /* @__PURE__ */ jsx("p", { children: "Debug Pipeline Flow" })
	})] }) }), k[9] = L, k[10] = j, k[11] = N, k[12] = K) : K = k[12];
	let q;
	k[13] === K ? q = k[14] : (q = /* @__PURE__ */ jsx(SidebarHeader, {
		className: "border-sidebar-border w-full flex-row items-center justify-between border-b p-2",
		children: /* @__PURE__ */ jsxs("div", {
			className: "flex items-center gap-1",
			children: [G, K]
		})
	}), k[13] = K, k[14] = q);
	let J;
	k[15] !== W || k[16] !== R || k[17] !== H || k[18] !== A || k[19] !== P || k[20] !== j || k[21] !== B || k[22] !== z ? (J = P && /* @__PURE__ */ jsxs(Tabs, {
		defaultValue: H(),
		className: "flex h-full w-full flex-col",
		children: [
			W > 1 && /* @__PURE__ */ jsxs(TabsList, {
				className: "w-full shrink-0",
				children: [
					R && /* @__PURE__ */ jsxs(TabsTrigger, {
						value: "codeExplorer",
						className: "flex items-center gap-1.5",
						children: [/* @__PURE__ */ jsx(Code, { className: "h-3.5 w-3.5" }), "Files"]
					}),
					z && /* @__PURE__ */ jsx(TabsTrigger, {
						value: "pipelineNavigation",
						children: "Navigation"
					}),
					B && /* @__PURE__ */ jsx(TabsTrigger, {
						value: "pipelineHistory",
						children: "History"
					})
				]
			}),
			R && /* @__PURE__ */ jsx(TabsContent, {
				value: "codeExplorer",
				className: "mt-2 flex min-h-0 flex-1 flex-col overflow-hidden",
				children: /* @__PURE__ */ jsx(CodeExplorer, {})
			}),
			z && /* @__PURE__ */ jsxs(TabsContent, {
				value: "pipelineNavigation",
				className: "mt-2",
				children: [/* @__PURE__ */ jsx(SidebarGroupLabel, { children: "Pipeline Navigation" }), /* @__PURE__ */ jsx(SidebarMenu, { children: j && A.length ? /* @__PURE__ */ jsx(WorkbenchNavigation_default, {
					namespaceTree: A,
					indent: 0
				}) : null })]
			}),
			B && /* @__PURE__ */ jsxs(TabsContent, {
				value: "pipelineHistory",
				className: "mt-2",
				children: [/* @__PURE__ */ jsx(SidebarGroupLabel, { children: "Run History" }), /* @__PURE__ */ jsx(SidebarMenu, { children: /* @__PURE__ */ jsx(PipelineHistoryList_default, { pipeline: j }) })]
			})
		]
	}), k[15] = W, k[16] = R, k[17] = H, k[18] = A, k[19] = P, k[20] = j, k[21] = B, k[22] = z, k[23] = J) : J = k[23];
	let Y;
	k[24] === J ? Y = k[25] : (Y = /* @__PURE__ */ jsx(SidebarContent, { children: /* @__PURE__ */ jsx(SidebarGroup, {
		className: "flex h-full flex-col",
		children: J
	}) }), k[24] = J, k[25] = Y);
	let X;
	k[26] === Symbol.for("react.memo_cache_sentinel") ? (X = /* @__PURE__ */ jsx(SidebarFooter, {}), k[26] = X) : X = k[26];
	let Z;
	return k[27] !== q || k[28] !== Y ? (Z = /* @__PURE__ */ jsxs(Sidebar, {
		side: "right",
		collapsible: "icon",
		className: "workbench-sidebar z-31",
		children: [
			q,
			Y,
			X
		]
	}), k[27] = q, k[28] = Y, k[29] = Z) : Z = k[29], Z;
};
export { WorkbenchSidebar_default as default };
