import { cn as e } from "../../../lib/utils.js";
import { Button as t } from "../../../components/ui/button.js";
import { Collapsible as n, CollapsibleContent as r, CollapsibleTrigger as i } from "../../../components/ui/collapsible.js";
import { getFileIcon as a, getFolderIcon as o } from "../utils/fileIcons.js";
import { jsx as s, jsxs as c } from "react/jsx-runtime";
import { ChevronDown as l, ChevronRight as u, X as d } from "lucide-react";
//#region src/features/code-explorer/components/CodeExplorerTreeNode.tsx
var f = 16, p = 8;
function m({ node: h, depth: g, onSelectFile: _, onClearSelection: v, onCloseFile: y, isSelected: b = !1, selectedFileId: x, expandedFolders: S = /* @__PURE__ */ new Set(), toggleFolder: C }) {
	let w = S.has(h.id), T = g * f + p, E = x === h.id || b;
	if (h.type === "file") {
		let n = a(h.name);
		return /* @__PURE__ */ c("div", {
			className: e("flex w-full min-w-0 items-center gap-2 rounded-sm py-1 group", "text-muted-foreground", E && "bg-muted"),
			style: { paddingLeft: T },
			children: [/* @__PURE__ */ c("button", {
				type: "button",
				className: e("flex flex-1 min-w-0 items-center gap-2 rounded-sm text-left text-sm hover:bg-muted/50", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),
				onClick: () => _?.(h),
				"aria-label": `Select file ${h.name}`,
				children: [/* @__PURE__ */ s(n, {
					className: "h-4 w-4 shrink-0 text-muted-foreground",
					"aria-hidden": !0
				}), /* @__PURE__ */ s("span", {
					className: "truncate",
					children: h.name
				})]
			}), E && (y || v) && /* @__PURE__ */ s(t, {
				variant: "ghost",
				size: "icon",
				className: "h-6 w-6 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",
				onClick: (e) => {
					e.stopPropagation(), y ? y(h) : v && v();
				},
				"aria-label": "Close file",
				children: /* @__PURE__ */ s(d, { className: "h-3.5 w-3.5" })
			})]
		});
	}
	let D = h.children && h.children.length > 0, O = o(w);
	return /* @__PURE__ */ c(n, {
		open: w,
		onOpenChange: () => {
			C && C(h.id);
		},
		children: [/* @__PURE__ */ c(i, {
			className: e("flex w-full min-w-0 items-center gap-1 rounded-sm py-1 text-left text-sm hover:bg-muted", "text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring", "disabled:cursor-default disabled:opacity-50"),
			style: { paddingLeft: T },
			disabled: !D,
			"aria-label": `${w ? "Collapse" : "Expand"} folder ${h.name}`,
			children: [
				D ? s(w ? l : u, {
					className: "h-4 w-4 shrink-0",
					"aria-hidden": !0
				}) : /* @__PURE__ */ s("span", {
					className: "w-4 shrink-0",
					"aria-hidden": !0
				}),
				/* @__PURE__ */ s(O, {
					className: "h-4 w-4 shrink-0 text-muted-foreground",
					"aria-hidden": !0
				}),
				/* @__PURE__ */ s("span", {
					className: "truncate",
					children: h.name
				})
			]
		}), D && /* @__PURE__ */ s(r, {
			className: "h-full",
			children: h.children.map((e) => /* @__PURE__ */ s(m, {
				node: e,
				depth: g + 1,
				onSelectFile: _,
				onClearSelection: v,
				onCloseFile: y,
				selectedFileId: x,
				expandedFolders: S,
				toggleFolder: C
			}, e.id))
		})]
	});
}
//#endregion
export { m as CodeExplorerTreeNode };
