"use client";
import { t as e } from "./useControlled-ZBScq72P.js";
import { t } from "./useIsoLayoutEffect-CKOv1bV_.js";
import { a as n, t as r, u as i } from "./useRenderElement-CmuWsiNa.js";
import { t as a } from "./useStableCallback-CqEVb76s.js";
import { n as o } from "./useCompositeListItem-xM6vOR9-.js";
import { t as s } from "./CompositeList-DJUJLDbx.js";
import { a as c, g as l, h as u, t as d, u as f } from "./createBaseUIEventDetails-ChcQXp54.js";
import { t as p } from "./useBaseUiId-DOm5ACje.js";
import { a as m, i as h, o as g, t as _ } from "./useOpenChangeComplete-DjMFUwhi.js";
import { t as v } from "./useButton-AXffhTAZ.js";
import { n as y, t as b } from "./shadowDom-C-4Ejp9R.js";
import { t as x } from "./owner-BrzQrszh.js";
import { cn as S } from "./lib/utils.js";
import { t as C } from "./dist-Ber_p4PA.js";
import { t as w } from "./inertValue-C36grUTu.js";
import { t as T } from "./useCompositeItem-DA_RDTEI.js";
import { n as E, t as D } from "./CompositeRoot-BIh8l7ys.js";
import * as O from "react";
import { jsx as k } from "react/jsx-runtime";
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/tabs/root/TabsRootContext.js
var A = /*#__PURE__*/ O.createContext(void 0);
process.env.NODE_ENV !== "production" && (A.displayName = "TabsRootContext");
function j() {
	let e = O.useContext(A);
	if (e === void 0) throw Error(process.env.NODE_ENV === "production" ? i(64) : "Base UI: TabsRootContext is missing. Tabs parts must be placed within <Tabs.Root>.");
	return e;
}
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/tabs/root/TabsRootDataAttributes.js
var M = /*#__PURE__*/ function(e) {
	return e.activationDirection = "data-activation-direction", e.orientation = "data-orientation", e;
}({}), N = { tabActivationDirection: (e) => ({ [M.activationDirection]: e }) }, P = /*#__PURE__*/ O.forwardRef(function(n, i) {
	let { className: o, defaultValue: l = 0, onValueChange: p, orientation: m = "horizontal", render: h, value: g, style: _, ...v } = n, y = n.defaultValue !== void 0, b = O.useRef([]), [x, S] = O.useState(() => /* @__PURE__ */ new Map()), [C, w] = e({
		controlled: g,
		default: l,
		name: "Tabs",
		state: "value"
	}), T = g !== void 0, [E, D] = O.useState(() => /* @__PURE__ */ new Map()), j = O.useCallback((e) => {
		if (e === void 0) return null;
		for (let [t, n] of E.entries()) if (n != null && e === (n.value ?? n.index)) return t;
		return null;
	}, [E]), [M, P] = O.useState(() => ({
		previousValue: C,
		tabActivationDirection: "none"
	})), { previousValue: I, tabActivationDirection: L } = M, R = L, z = !1;
	I !== C && (R = F(I, C, m, E), z = I != null && C != null && j(C) == null);
	let B = z ? I : C, V = I !== B || L !== R;
	t(() => {
		V && P({
			previousValue: B,
			tabActivationDirection: R
		});
	}, [
		B,
		V,
		R
	]);
	let H = a((e, t) => {
		t.activationDirection = F(C, e, m, E), p?.(e, t), !t.isCanceled && w(e);
	}), U = a((e, t) => {
		p?.(e, d(t, void 0, void 0, { activationDirection: "none" }));
	}), W = a((e, t) => {
		S((n) => {
			if (n.get(e) === t) return n;
			let r = new Map(n);
			return r.set(e, t), r;
		});
	}), G = a((e, t) => {
		S((n) => {
			if (!n.has(e) || n.get(e) !== t) return n;
			let r = new Map(n);
			return r.delete(e), r;
		});
	}), K = O.useCallback((e) => x.get(e), [x]), q = O.useCallback((e) => {
		for (let t of E.values()) if (e === t?.value) return t?.id;
	}, [E]), J = O.useMemo(() => ({
		getTabElementBySelectedValue: j,
		getTabIdByPanelValue: q,
		getTabPanelIdByValue: K,
		onValueChange: H,
		orientation: m,
		registerMountedTabPanel: W,
		setTabMap: D,
		unregisterMountedTabPanel: G,
		tabActivationDirection: R,
		value: C
	}), [
		j,
		q,
		K,
		H,
		m,
		W,
		D,
		G,
		R,
		C
	]), Y = O.useMemo(() => {
		for (let e of E.values()) if (e != null && e.value === C) return e;
	}, [E, C]), X = O.useMemo(() => {
		for (let e of E.values()) if (e != null && !e.disabled) return e.value;
	}, [E]), Z = O.useRef(!y), Q = O.useRef(y), $ = O.useRef(!1);
	t(() => {
		if (T) return;
		function e(e, t) {
			w(e), P((t) => t.previousValue === e && t.tabActivationDirection === "none" ? t : {
				previousValue: e,
				tabActivationDirection: "none"
			}), U(e, t), Z.current = !1;
		}
		if (E.size === 0) {
			if (!$.current || C === null) return;
			e(null, u);
			return;
		}
		$.current = !0;
		let t = Y?.disabled, n = Y == null && C !== null;
		if (!t && C === l && (Q.current = !1), Q.current && t && C === l) return;
		let r = Z.current;
		if (t || n) {
			let n = X ?? null;
			if (C === n) {
				Z.current = !1;
				return;
			}
			let i = u;
			r ? i = f : t && (i = c), e(n, i);
			return;
		}
		r && Y != null && (U(C, f), Z.current = !1);
	}, [
		l,
		X,
		T,
		U,
		Y,
		w,
		E,
		C
	]);
	let ee = r("div", n, {
		state: {
			orientation: m,
			tabActivationDirection: R
		},
		ref: i,
		props: v,
		stateAttributesMapping: N
	});
	return /*#__PURE__*/ k(A.Provider, {
		value: J,
		children: /*#__PURE__*/ k(s, {
			elementsRef: b,
			children: ee
		})
	});
});
process.env.NODE_ENV !== "production" && (P.displayName = "TabsRoot");
function F(e, t, n, r) {
	if (e == null || t == null) return "none";
	let i = null, a = null;
	for (let [n, o] of r.entries()) {
		if (o == null) continue;
		let r = o.value ?? o.index;
		if (e === r && (i = n), t === r && (a = n), i != null && a != null) break;
	}
	if (i == null || a == null) return i !== a && (typeof e == "number" || typeof e == "string") && typeof e == typeof t ? n === "horizontal" ? t > e ? "right" : "left" : t > e ? "down" : "up" : "none";
	let o = i.getBoundingClientRect(), s = a.getBoundingClientRect();
	if (n === "horizontal") {
		if (s.left < o.left) return "left";
		if (s.left > o.left) return "right";
	} else {
		if (s.top < o.top) return "up";
		if (s.top > o.top) return "down";
	}
	return "none";
}
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/tabs/list/TabsListContext.js
var I = /*#__PURE__*/ O.createContext(void 0);
process.env.NODE_ENV !== "production" && (I.displayName = "TabsListContext");
function L() {
	let e = O.useContext(I);
	if (e === void 0) throw Error(process.env.NODE_ENV === "production" ? i(65) : "Base UI: TabsListContext is missing. TabsList parts must be placed within <Tabs.List>.");
	return e;
}
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/tabs/tab/TabsTab.js
var R = /*#__PURE__*/ O.forwardRef(function(e, n) {
	let { className: i, disabled: a = !1, render: o, value: s, id: c, nativeButton: u = !0, style: f, ...m } = e, { value: h, getTabPanelIdByValue: g, orientation: _ } = j(), { activateOnFocus: S, highlightedTabIndex: C, onTabActivation: w, registerTabResizeObserverElement: D, setHighlightedTabIndex: k, tabsListElement: A } = L(), M = p(c), { compositeProps: N, compositeRef: P, index: F } = T({ metadata: O.useMemo(() => ({
		disabled: a,
		id: M,
		value: s
	}), [
		a,
		M,
		s
	]) }), I = s === h, R = O.useRef(!1), z = O.useRef(null);
	O.useEffect(() => {
		let e = z.current;
		if (e) return D(e);
	}, [D]), t(() => {
		if (R.current) {
			R.current = !1;
			return;
		}
		if (!(I && F > -1 && C !== F)) return;
		let e = A;
		if (e != null) {
			let t = b(x(e));
			if (t && y(e, t)) return;
		}
		a || k(F);
	}, [
		I,
		F,
		C,
		k,
		a,
		A
	]);
	let { getButtonProps: B, buttonRef: V } = v({
		disabled: a,
		native: u,
		focusableWhenDisabled: !0
	}), H = g(s), U = O.useRef(!1), W = O.useRef(!1);
	function G(e) {
		I || a || w(s, d(l, e.nativeEvent, void 0, { activationDirection: "none" }));
	}
	function K(e) {
		I || (F > -1 && !a && k(F), !a && S && (!U.current || U.current && W.current) && w(s, d(l, e.nativeEvent, void 0, { activationDirection: "none" })));
	}
	function q(e) {
		if (I || a) return;
		U.current = !0;
		function t() {
			U.current = !1, W.current = !1;
		}
		(!e.button || e.button === 0) && (W.current = !0, x(e.currentTarget).addEventListener("pointerup", t, { once: !0 }));
	}
	return r("button", e, {
		state: {
			disabled: a,
			active: I,
			orientation: _
		},
		ref: [
			n,
			V,
			P,
			z
		],
		props: [
			N,
			{
				role: "tab",
				"aria-controls": H,
				"aria-selected": I,
				id: M,
				onClick: G,
				onFocus: K,
				onPointerDown: q,
				[E]: I ? "" : void 0,
				onKeyDownCapture() {
					R.current = !0;
				}
			},
			m,
			B
		]
	});
});
process.env.NODE_ENV !== "production" && (R.displayName = "TabsTab");
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/tabs/panel/TabsPanelDataAttributes.js
var z = function(e) {
	return e.index = "data-index", e.activationDirection = "data-activation-direction", e.orientation = "data-orientation", e.hidden = "data-hidden", e[e.startingStyle = h.startingStyle] = "startingStyle", e[e.endingStyle = h.endingStyle] = "endingStyle", e;
}({}), B = {
	...N,
	...m
}, V = /*#__PURE__*/ O.forwardRef(function(e, n) {
	let { className: i, value: a, render: s, keepMounted: c = !1, style: l, ...u } = e, { value: d, getTabIdByPanelValue: f, orientation: m, tabActivationDirection: h, registerMountedTabPanel: v, unregisterMountedTabPanel: y } = j(), b = p(), { ref: x, index: S } = o({ metadata: O.useMemo(() => ({
		id: b,
		value: a
	}), [b, a]) }), C = a === d, { mounted: T, transitionStatus: E, setMounted: D } = g(C), k = !T, A = f(a), M = {
		hidden: k,
		orientation: m,
		tabActivationDirection: h,
		transitionStatus: E
	}, N = O.useRef(null), P = r("div", e, {
		state: M,
		ref: [
			n,
			x,
			N
		],
		props: [{
			"aria-labelledby": A,
			hidden: k,
			id: b,
			role: "tabpanel",
			tabIndex: C ? 0 : -1,
			inert: w(!C),
			[z.index]: S
		}, u],
		stateAttributesMapping: B
	});
	return _({
		open: C,
		ref: N,
		onComplete() {
			C || D(!1);
		}
	}), t(() => {
		if (!(k && !c) && b != null) return v(a, b), () => {
			y(a, b);
		};
	}, [
		k,
		c,
		a,
		b,
		v,
		y
	]), c || T ? P : null;
});
process.env.NODE_ENV !== "production" && (V.displayName = "TabsPanel");
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/tabs/list/TabsList.js
var H = /*#__PURE__*/ O.forwardRef(function(e, t) {
	let { activateOnFocus: r = !1, className: i, loopFocus: o = !0, render: s, style: c, ...l } = e, { onValueChange: u, orientation: d, value: f, setTabMap: p, tabActivationDirection: m } = j(), [h, g] = O.useState(0), [_, v] = O.useState(null), y = O.useRef(/* @__PURE__ */ new Set()), b = O.useRef(/* @__PURE__ */ new Set()), x = O.useRef(null);
	O.useEffect(() => {
		if (typeof ResizeObserver > "u") return;
		let e = new ResizeObserver(() => {
			y.current.forEach((e) => {
				e();
			});
		});
		return x.current = e, _ && e.observe(_), b.current.forEach((t) => {
			e.observe(t);
		}), () => {
			e.disconnect(), x.current = null;
		};
	}, [_]);
	let S = a((e) => (y.current.add(e), () => {
		y.current.delete(e);
	})), C = a((e) => (b.current.add(e), x.current?.observe(e), () => {
		b.current.delete(e), x.current?.unobserve(e);
	})), w = a((e, t) => {
		e !== f && u(e, t);
	}), T = {
		orientation: d,
		tabActivationDirection: m
	}, E = {
		"aria-orientation": d === "vertical" ? "vertical" : void 0,
		role: "tablist"
	}, A = O.useMemo(() => ({
		activateOnFocus: r,
		highlightedTabIndex: h,
		registerIndicatorUpdateListener: S,
		registerTabResizeObserverElement: C,
		onTabActivation: w,
		setHighlightedTabIndex: g,
		tabsListElement: _
	}), [
		r,
		h,
		S,
		C,
		w,
		g,
		_
	]);
	return /*#__PURE__*/ k(I.Provider, {
		value: A,
		children: /*#__PURE__*/ k(D, {
			render: s,
			className: i,
			style: c,
			state: T,
			refs: [t, v],
			props: [E, l],
			stateAttributesMapping: N,
			highlightedIndex: h,
			enableHomeAndEndKeys: !0,
			loopFocus: o,
			orientation: d,
			onHighlightedIndexChange: g,
			onMapChange: p,
			disabledIndices: n
		})
	});
});
process.env.NODE_ENV !== "production" && (H.displayName = "TabsList");
//#endregion
//#region lib/components/ui/atoms/tabs.tsx
function U({ className: e, orientation: t = "horizontal", ...n }) {
	return /* @__PURE__ */ k(P, {
		className: S("group/tabs flex gap-2 data-[orientation=horizontal]:flex-col", e),
		"data-slot": "tabs",
		orientation: t,
		...n
	});
}
var W = C("group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground data-[variant=line]:rounded-none group-data-[orientation=horizontal]/tabs:h-8 group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col", {
	variants: { variant: {
		default: "bg-muted",
		line: "gap-1 bg-transparent"
	} },
	defaultVariants: { variant: "default" }
});
function G({ className: e, variant: t = "default", ...n }) {
	return /* @__PURE__ */ k(H, {
		className: S(W({ variant: t }), e),
		"data-slot": "tabs-list",
		"data-variant": t,
		...n
	});
}
function K({ className: e, ...t }) {
	return /* @__PURE__ */ k(R, {
		className: S("relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 whitespace-nowrap rounded-md border border-transparent px-1.5 py-0.5 font-medium text-foreground/60 text-sm transition-all hover:text-foreground focus-visible:border-ring focus-visible:outline-1 focus-visible:outline-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 aria-disabled:pointer-events-none aria-disabled:opacity-50 group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none dark:text-muted-foreground dark:hover:text-foreground [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0", "group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent", "data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground", "after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-[orientation=horizontal]/tabs:after:inset-x-0 group-data-[orientation=vertical]/tabs:after:inset-y-0 group-data-[orientation=vertical]/tabs:after:-right-1 group-data-[orientation=horizontal]/tabs:after:bottom-[-5px] group-data-[orientation=horizontal]/tabs:after:h-0.5 group-data-[orientation=vertical]/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100", e),
		"data-slot": "tabs-trigger",
		...t
	});
}
function q({ className: e, ...t }) {
	return /* @__PURE__ */ k(V, {
		className: S("flex-1 text-sm outline-none", e),
		"data-slot": "tabs-content",
		...t
	});
}
//#endregion
export { W as a, K as i, q as n, G as r, U as t };
