import { Background as e, BackgroundVariant as t, Controls as n, index as r, useEdgesState as i, useNodesState as a, useReactFlow as o } from "../../../node_modules/@xyflow/react/dist/esm/index.js";
/* empty css                                             */
import s from "./workflow-flow/StateNode.js";
import { buildWorkflowGraph as c } from "../lib/flow-utils.js";
import l from "./workflow-flow/WorkflowTransitionEdge.js";
import { useEffect as u, useRef as d } from "react";
import { jsx as f, jsxs as p } from "react/jsx-runtime";
import { Loader2 as m } from "lucide-react";
//#region src/features/debug/components/ConfigFlowViewer.tsx
var h = { stateNode: s }, g = { workflowTransition: l }, _ = ({ config: s }) => {
	let [l, _, v] = a([]), [y, b, x] = i([]), { fitView: S } = o(), C = d(!1);
	return u(() => {
		if (!s) return;
		let { nodes: e, edges: t } = c(s, void 0, "preview", s.transitions ?? [], "TB", !0);
		_(e), b(t);
	}, [
		s,
		_,
		b
	]), u(() => {
		if (l.length > 0 && !C.current) {
			C.current = !0;
			let e = setTimeout(() => {
				S({ padding: .2 });
			}, 150);
			return () => clearTimeout(e);
		}
	}, [l.length, S]), s ? l.length === 0 ? /* @__PURE__ */ f("div", {
		className: "text-muted-foreground flex h-full items-center justify-center",
		children: /* @__PURE__ */ f("p", {
			className: "font-medium",
			children: "No transitions defined in configuration"
		})
	}) : /* @__PURE__ */ f("div", {
		className: "h-full w-full bg-background",
		children: /* @__PURE__ */ p(r, {
			nodes: l,
			edges: y,
			onNodesChange: v,
			onEdgesChange: x,
			nodeTypes: h,
			edgeTypes: g,
			fitView: !0,
			minZoom: .1,
			maxZoom: 2,
			proOptions: { hideAttribution: !0 },
			className: "bg-background",
			children: [/* @__PURE__ */ f(e, {
				variant: t.Cross,
				gap: 24,
				size: 1,
				className: "opacity-[0.15]"
			}), /* @__PURE__ */ f(n, { className: "bg-card border-border rounded-lg border shadow-md" })]
		})
	}) : /* @__PURE__ */ f("div", {
		className: "flex h-full items-center justify-center",
		children: /* @__PURE__ */ f(m, { className: "h-6 w-6 animate-spin text-muted-foreground" })
	});
};
//#endregion
export { _ as default };
