import { useWorkflow } from "../../../../hooks/useWorkflows.js";
import { buildWorkflowGraph, getTransitions } from "../../lib/flow-utils.js";
import { c } from "react/compiler-runtime";
import React, { useEffect, useRef } from "react";
function countTransitions(e) {
	return e ? getTransitions(e).length : 0;
}
var WorkflowGraph_default = (s) => {
	let l = c(17), { pipeline: u, workflow: d, pipelineConfig: f, onGraphReady: p, onLoadingChange: m } = s, h = useWorkflow(d.id), g = h.data, _ = useRef(null), v, y;
	l[0] !== h.isLoading || l[1] !== m || l[2] !== d.id ? (v = () => {
		m(d.id, h.isLoading);
	}, y = [
		d.id,
		h.isLoading,
		m
	], l[0] = h.isLoading, l[1] = m, l[2] = d.id, l[3] = v, l[4] = y) : (v = l[3], y = l[4]), useEffect(v, y);
	let b;
	l[5] !== p || l[6] !== u || l[7] !== f || l[8] !== d.id || l[9] !== g ? (b = () => {
		let e = f ? getTransitions(f) : [], o = JSON.stringify({
			p: countTransitions(u),
			w: countTransitions(g),
			c: e.length,
			history: g?.history?.length,
			place: g?.place
		});
		if (o !== _.current) {
			_.current = o;
			let { nodes: a, edges: s } = buildWorkflowGraph(u, g, d.id, e, "LR");
			p(d.id, a, s);
		}
	}, l[5] = p, l[6] = u, l[7] = f, l[8] = d.id, l[9] = g, l[10] = b) : b = l[10];
	let x;
	return l[11] !== p || l[12] !== u || l[13] !== f || l[14] !== d || l[15] !== g ? (x = [
		u,
		d,
		g,
		f,
		p
	], l[11] = p, l[12] = u, l[13] = f, l[14] = d, l[15] = g, l[16] = x) : x = l[16], useEffect(b, x), null;
};
export { WorkflowGraph_default as default };
