import { cn } from "../../../../lib/utils.js";
import { Badge } from "../../../../components/ui/badge.js";
import { Position } from "../../../../node_modules/@xyflow/system/dist/esm/index.js";
import { Handle } from "../../../../node_modules/@xyflow/react/dist/esm/index.js";
import { c } from "react/compiler-runtime";
import React from "react";
import { jsx, jsxs } from "react/jsx-runtime";
var HIDDEN_HANDLE = "!bg-muted-foreground/30 !h-3 !w-1 !rounded-sm opacity-0", HIDDEN_HANDLE_WIDE = "!bg-muted-foreground/30 !h-1 !w-3 !rounded-sm opacity-0";
function getNodeClassName(e) {
	return e.isCurrent ? "border-primary shadow-primary/20 bg-primary/5 ring-primary/30 z-10 shadow-lg ring-4" : e.isEnd ? "border-green-500/30 bg-green-500/10" : e.isStart ? "border-blue-500/30 bg-blue-500/10" : e.isVisited ? "border-border/60 bg-muted/40" : `border-border/40 bg-card/60 ${e.forceVisible ? "opacity-100" : "opacity-80 hover:opacity-100"}`;
}
function getLabelClassName(e) {
	return e.isCurrent ? "text-primary font-semibold" : e.isVisited ? "text-foreground" : "text-muted-foreground";
}
function getPositions(e) {
	let l = e === "LR";
	return {
		target: l ? Position.Left : Position.Top,
		source: l ? Position.Right : Position.Bottom,
		backEdge: l ? Position.Bottom : Position.Right
	};
}
var StateNode = (l) => {
	let u = c(29), { data: f } = l, g;
	u[0] === f.direction ? g = u[1] : (g = getPositions(f.direction), u[0] = f.direction, u[1] = g);
	let _ = g, v;
	u[2] === f ? v = u[3] : (v = cn("relative flex min-w-32 flex-col items-center gap-2 rounded-xl border px-5 py-3 shadow-sm transition-all duration-300", getNodeClassName(f)), u[2] = f, u[3] = v);
	let y;
	u[4] === f.isCurrent ? y = u[5] : (y = f.isCurrent && /* @__PURE__ */ jsx(CurrentIndicator, {}), u[4] = f.isCurrent, u[5] = y);
	let b;
	u[6] === _.target ? b = u[7] : (b = /* @__PURE__ */ jsx(Handle, {
		type: "target",
		position: _.target,
		className: HIDDEN_HANDLE
	}), u[6] = _.target, u[7] = b);
	let x;
	u[8] === _.source ? x = u[9] : (x = /* @__PURE__ */ jsx(Handle, {
		type: "source",
		position: _.source,
		className: HIDDEN_HANDLE
	}), u[8] = _.source, u[9] = x);
	let S, C;
	u[10] === _.backEdge ? (S = u[11], C = u[12]) : (S = /* @__PURE__ */ jsx(Handle, {
		type: "source",
		id: "bottom-source",
		position: _.backEdge,
		className: HIDDEN_HANDLE_WIDE
	}), C = /* @__PURE__ */ jsx(Handle, {
		type: "target",
		id: "bottom-target",
		position: _.backEdge,
		className: HIDDEN_HANDLE_WIDE
	}), u[10] = _.backEdge, u[11] = S, u[12] = C);
	let w;
	u[13] === f ? w = u[14] : (w = cn("text-sm font-medium tracking-tight", getLabelClassName(f)), u[13] = f, u[14] = w);
	let T;
	u[15] !== f.label || u[16] !== w ? (T = /* @__PURE__ */ jsx("span", {
		className: w,
		children: f.label
	}), u[15] = f.label, u[16] = w, u[17] = T) : T = u[17];
	let E;
	u[18] === f ? E = u[19] : (E = /* @__PURE__ */ jsx(StatusBadges, { data: f }), u[18] = f, u[19] = E);
	let D;
	return u[20] !== E || u[21] !== v || u[22] !== y || u[23] !== b || u[24] !== x || u[25] !== S || u[26] !== C || u[27] !== T ? (D = /* @__PURE__ */ jsxs("div", {
		className: v,
		children: [
			y,
			b,
			x,
			S,
			C,
			T,
			E
		]
	}), u[20] = E, u[21] = v, u[22] = y, u[23] = b, u[24] = x, u[25] = S, u[26] = C, u[27] = T, u[28] = D) : D = u[28], D;
}, CurrentIndicator = () => {
	let e = c(1), l;
	return e[0] === Symbol.for("react.memo_cache_sentinel") ? (l = /* @__PURE__ */ jsxs("span", {
		className: "absolute -top-1 -right-1 flex h-3 w-3",
		children: [/* @__PURE__ */ jsx("span", { className: "bg-primary/50 absolute inline-flex h-full w-full animate-ping rounded-full opacity-75" }), /* @__PURE__ */ jsx("span", { className: "bg-primary relative inline-flex h-3 w-3 rounded-full" })]
	}), e[0] = l) : l = e[0], l;
}, StatusBadges = (e) => {
	let u = c(10), { data: d } = e, f;
	u[0] === d.visitCount ? f = u[1] : (f = d.visitCount > 1 && /* @__PURE__ */ jsxs(Badge, {
		variant: "secondary",
		className: "bg-secondary/50 text-secondary-foreground hover:bg-secondary/70 h-5 px-1.5 text-[10px]",
		children: [d.visitCount, "x"]
	}), u[0] = d.visitCount, u[1] = f);
	let p;
	u[2] === d.isEnd ? p = u[3] : (p = d.isEnd && /* @__PURE__ */ jsx(Badge, {
		variant: "outline",
		className: "h-5 border-green-500/30 bg-green-500/5 px-1.5 text-[10px] text-green-600",
		children: "End"
	}), u[2] = d.isEnd, u[3] = p);
	let m;
	u[4] === d.isStart ? m = u[5] : (m = d.isStart && /* @__PURE__ */ jsx(Badge, {
		variant: "outline",
		className: "h-5 border-blue-500/30 bg-blue-500/5 px-1.5 text-[10px] text-blue-600",
		children: "Start"
	}), u[4] = d.isStart, u[5] = m);
	let h;
	return u[6] !== f || u[7] !== p || u[8] !== m ? (h = /* @__PURE__ */ jsxs("div", {
		className: "flex items-center gap-1.5",
		children: [
			f,
			p,
			m
		]
	}), u[6] = f, u[7] = p, u[8] = m, u[9] = h) : h = u[9], h;
}, StateNode_default = StateNode;
export { StateNode_default as default };
