import { cx as e } from "../../../theme/tools.js";
import { actionSlot as t, actions as n, actionsVisible as ee, badge as r, badgeCollapsed as te, dragHandle as ne, icon as i, iconNested as re, item as ie, itemActive as ae, itemCollapsed as a, itemDisabled as o, itemNested as s, label as c, labelCollapsed as l, link as u } from "./sidebarNavItem.css.js";
import { useCallback as d, useEffect as oe, useRef as f, useState as p } from "react";
import { Fragment as se, jsx as m, jsxs as h } from "react/jsx-runtime";
import g from "@plumile/router/routing/Link.js";
//#region src/backoffice/molecules/sidebar_nav_item/SidebarNavItem.tsx
var ce = g, _ = ({ label: g, href: _, icon: v, badge: y, isActive: b = !1, disabled: x = !1, onClick: S, onDragStart: le, onDragOver: ue, onDrop: de, onDragEnd: fe, collapsed: C = !1, nested: w = !1, ariaLabel: pe, className: T, actionSlot: E, dragHandleSlot: D, dragHandleLabel: O, draggable: k = !1 }) => {
	let A = f(null), j = f(null), [M, N] = p(!1), [P, F] = p(!1), I = [ie];
	C && I.push(a), w && !C && I.push(s), b && I.push(ae), x && I.push(o), T != null && I.push(T);
	let L = e(...I), R = pe;
	R == null && typeof g == "string" && (R = g);
	let z, B;
	C && (z = R, B = R);
	let V;
	b && (V = "page");
	let H = null;
	v != null && (H = /* @__PURE__ */ m("span", {
		className: e(i, { [re]: w && !C }),
		children: v
	}));
	let U = null;
	C && (U = l);
	let me = e(c, U), W = null;
	if (y != null) {
		let t = null;
		C && (t = te), W = /* @__PURE__ */ m("span", {
			className: e(r, t),
			children: y
		});
	}
	let G = /* @__PURE__ */ h(se, { children: [
		H,
		/* @__PURE__ */ m("span", {
			className: me,
			children: g
		}),
		W
	] }), K = () => {
		S?.();
	}, q = !C && !x && (E != null || D != null), J = d(() => {
		j.current != null && (clearTimeout(j.current), j.current = null);
	}, []);
	oe(() => (q || (N(!1), F(!1), J()), () => {
		J();
	}), [J, q]);
	let he = () => {
		q && (J(), j.current = setTimeout(() => {
			N(!0);
		}, 150));
	}, ge = () => {
		J(), N(!1);
	}, _e = () => {
		q && F(!0);
	}, ve = (e) => {
		if (!q) {
			F(!1);
			return;
		}
		let t = e.relatedTarget;
		t != null && A.current?.contains(t) || F(!1);
	}, Y;
	Y = x ? /* @__PURE__ */ m("span", {
		className: u,
		"aria-disabled": "true",
		"aria-label": z,
		title: B,
		children: G
	}) : _ == null ? /* @__PURE__ */ m("button", {
		type: "button",
		className: u,
		onClick: K,
		"aria-current": V,
		"aria-label": z,
		title: B,
		children: G
	}) : /* @__PURE__ */ m(ce, {
		to: _,
		className: u,
		"aria-current": V,
		"aria-label": z,
		title: B,
		onClick: K,
		children: G
	});
	let ye = q && (M || P), X;
	ye && (X = ee);
	let be = e(n, X), Z = null;
	D != null && !C && (Z = /* @__PURE__ */ m("button", {
		type: "button",
		className: ne,
		draggable: k,
		onDragStart: le,
		onDragEnd: fe,
		"aria-label": O,
		title: O,
		children: D
	}));
	let Q = null;
	E != null && !C && (Q = /* @__PURE__ */ m("span", {
		className: t,
		children: E
	}));
	let $ = null;
	return q && ($ = /* @__PURE__ */ h("span", {
		className: be,
		children: [Z, Q]
	})), /* @__PURE__ */ h("div", {
		className: L,
		onDragOver: ue,
		onDrop: de,
		onMouseEnter: he,
		onMouseLeave: ge,
		onFocusCapture: _e,
		onBlurCapture: ve,
		ref: A,
		role: "listitem",
		children: [Y, $]
	});
};
//#endregion
export { _ as SidebarNavItem, _ as default };

//# sourceMappingURL=SidebarNavItem.js.map