import { Button as e } from "../../../components/ui/button.js";
import { ScrollArea as t } from "../../../components/ui/scroll-area.js";
import { CodeExplorerTreeNode as n } from "../../code-explorer/components/CodeExplorerTreeNode.js";
import { useRemoteFileExplorer as r } from "../providers/RemoteFileExplorerProvider.js";
import { jsx as i, jsxs as a } from "react/jsx-runtime";
import { AlertCircle as o, Loader2 as s, RefreshCw as c } from "lucide-react";
//#region src/features/workbench/components/RemoteFileTree.tsx
var l = () => {
	let { nodes: l, isTreeLoading: u, treeError: d, isFetchingTree: f, expandedFolders: p, toggleFolder: m, selectFile: h, closeFile: g, selectedFile: _, refreshTree: v } = r();
	return u ? /* @__PURE__ */ a("div", {
		className: "flex items-center gap-2 p-3 text-sm text-muted-foreground",
		children: [/* @__PURE__ */ i(s, { className: "h-4 w-4 animate-spin" }), "Loading file tree…"]
	}) : d ? /* @__PURE__ */ a("div", {
		className: "space-y-2 p-3",
		children: [/* @__PURE__ */ a("div", {
			className: "flex items-start gap-2 text-sm text-destructive",
			children: [/* @__PURE__ */ i(o, { className: "mt-0.5 h-4 w-4 shrink-0" }), /* @__PURE__ */ i("span", { children: d instanceof Error ? d.message : String(d) })]
		}), /* @__PURE__ */ a(e, {
			variant: "outline",
			size: "sm",
			onClick: v,
			children: [/* @__PURE__ */ i(c, { className: "mr-1.5 h-3.5 w-3.5" }), "Retry"]
		})]
	}) : l.length === 0 ? /* @__PURE__ */ i("p", {
		className: "px-2 py-4 text-sm text-muted-foreground",
		children: "No files found"
	}) : /* @__PURE__ */ a("div", {
		className: "flex h-full flex-col gap-1.5",
		children: [/* @__PURE__ */ i("div", {
			className: "flex items-center justify-end px-1",
			children: /* @__PURE__ */ i(e, {
				variant: "ghost",
				size: "icon",
				className: "h-6 w-6",
				onClick: v,
				disabled: f,
				children: /* @__PURE__ */ i(c, { className: `h-3 w-3 ${f ? "animate-spin" : ""}` })
			})
		}), /* @__PURE__ */ i(t, {
			className: "h-full w-full",
			children: /* @__PURE__ */ i("div", {
				className: "w-full py-1",
				role: "tree",
				"aria-label": "Remote file tree",
				children: l.map((e) => /* @__PURE__ */ i(n, {
					node: e,
					depth: 0,
					expandedFolders: p,
					toggleFolder: m,
					onSelectFile: h,
					onCloseFile: g,
					selectedFileId: _?.id
				}, e.id))
			})
		})]
	});
};
//#endregion
export { l as default };
