"use client";
import { t as e } from "./useControlled-ZBScq72P.js";
import { t } from "./useIsoLayoutEffect-CKOv1bV_.js";
import { d as n, i as r, l as i, t as a, u as o } from "./useRenderElement-CmuWsiNa.js";
import { t as s } from "./useStableCallback-CqEVb76s.js";
import { n as c } from "./useCompositeListItem-xM6vOR9-.js";
import { t as l } from "./CompositeList-DJUJLDbx.js";
import { t as u } from "./DirectionContext-B4CbbM--.js";
import { g as d, t as f } from "./createBaseUIEventDetails-ChcQXp54.js";
import { t as p } from "./useBaseUiId-DOm5ACje.js";
import { a as m } from "./useOpenChangeComplete-DjMFUwhi.js";
import { a as h, i as g, n as _, o as v, r as y, t as b } from "./useCollapsiblePanel-B7ERXY1c.js";
import { t as x } from "./isElementDisabled-Cibvw8mz.js";
import { t as S } from "./useButton-AXffhTAZ.js";
import { o as C } from "./event-DWcDp5kt.js";
import { a as w, i as T, o as E, r as D, t as O } from "./composite-BlDfbDkL.js";
import { cn as k } from "./lib/utils.js";
import * as A from "react";
import { jsx as j, jsxs as M } from "react/jsx-runtime";
import { ChevronDownIcon as N, ChevronUpIcon as P } from "lucide-react";
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/accordion/root/AccordionRootContext.js
var F = /*#__PURE__*/ A.createContext(void 0);
process.env.NODE_ENV !== "production" && (F.displayName = "AccordionRootContext");
function I() {
	let e = A.useContext(F);
	if (e === void 0) throw Error(process.env.NODE_ENV === "production" ? o(10) : "Base UI: AccordionRootContext is missing. Accordion parts must be placed within <Accordion.Root>.");
	return e;
}
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/accordion/root/AccordionRoot.js
var L = { value: () => null }, R = /*#__PURE__*/ A.forwardRef(function(r, i) {
	let { render: o, className: c, disabled: p = !1, hiddenUntilFound: m, keepMounted: h, loopFocus: g = !0, onValueChange: _, multiple: v = !1, orientation: y = "vertical", value: b, defaultValue: x, style: S, ...C } = r, w = u();
	process.env.NODE_ENV !== "production" && t(() => {
		m && h === !1 && n("The `keepMounted={false}` prop on `Accordion.Root` is ignored when `hiddenUntilFound` is enabled, since panels must remain mounted while closed.");
	}, [m, h]);
	let T = A.useMemo(() => {
		if (b === void 0) return x ?? [];
	}, [b, x]), E = A.useRef([]), [D, O] = e({
		controlled: b,
		default: T,
		name: "Accordion",
		state: "value"
	}), k = s((e, t) => {
		let n = f(d);
		if (!v) {
			let t = D[0] === e ? [] : [e];
			if (_?.(t, n), n.isCanceled) return;
			O(t);
		} else if (t) {
			let t = D.slice();
			if (t.push(e), _?.(t, n), n.isCanceled) return;
			O(t);
		} else {
			let t = D.filter((t) => t !== e);
			if (_?.(t, n), n.isCanceled) return;
			O(t);
		}
	}), M = A.useMemo(() => ({
		value: D,
		disabled: p,
		orientation: y
	}), [
		D,
		p,
		y
	]), N = A.useMemo(() => ({
		accordionItemRefs: E,
		direction: w,
		disabled: p,
		handleValueChange: k,
		hiddenUntilFound: m ?? !1,
		keepMounted: h ?? !1,
		loopFocus: g,
		orientation: y,
		state: M,
		value: D
	}), [
		w,
		p,
		k,
		m,
		h,
		g,
		y,
		M,
		D
	]), P = a("div", r, {
		state: M,
		ref: i,
		props: [{
			dir: w,
			role: "region"
		}, C],
		stateAttributesMapping: L
	});
	return /*#__PURE__*/ j(F.Provider, {
		value: N,
		children: /*#__PURE__*/ j(l, {
			elementsRef: E,
			children: P
		})
	});
});
process.env.NODE_ENV !== "production" && (R.displayName = "AccordionRoot");
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/accordion/item/AccordionItemContext.js
var z = /*#__PURE__*/ A.createContext(void 0);
process.env.NODE_ENV !== "production" && (z.displayName = "AccordionItemContext");
function B() {
	let e = A.useContext(z);
	if (e === void 0) throw Error(process.env.NODE_ENV === "production" ? o(9) : "Base UI: AccordionItemContext is missing. Accordion parts must be placed within <Accordion.Item>.");
	return e;
}
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/accordion/item/AccordionItemDataAttributes.js
var V = /*#__PURE__*/ function(e) {
	return e.index = "data-index", e.disabled = "data-disabled", e.open = "data-open", e;
}({}), H = {
	..._,
	index: (e) => Number.isInteger(e) ? { [V.index]: String(e) } : null,
	...m,
	value: () => null
}, U = /*#__PURE__*/ A.forwardRef(function(e, t) {
	let { className: n, disabled: r = !1, onOpenChange: o, render: l, value: u, style: d, ...f } = e, { ref: m, index: h } = c(), _ = i(t, m), { disabled: y, handleValueChange: b, state: x, value: S } = I(), C = p(), w = u ?? C, T = r || y, E = A.useMemo(() => {
		if (!S) return !1;
		for (let e = 0; e < S.length; e += 1) if (S[e] === w) return !0;
		return !1;
	}, [S, w]), D = s((e, t) => {
		o?.(e, t), !t.isCanceled && b(w, e);
	}), O = v({
		open: E,
		onOpenChange: D,
		disabled: T
	}), k = A.useMemo(() => ({
		open: O.open,
		disabled: O.disabled,
		transitionStatus: O.transitionStatus
	}), [
		O.open,
		O.disabled,
		O.transitionStatus
	]), M = A.useMemo(() => ({
		...O,
		onOpenChange: D,
		state: k
	}), [
		O,
		k,
		D
	]), N = A.useMemo(() => ({
		...x,
		hidden: !E && !O.mounted,
		index: h,
		disabled: T,
		open: E
	}), [
		O.mounted,
		T,
		h,
		E,
		x
	]), P = p(), [F, L] = A.useState(P), R = A.useMemo(() => ({
		open: E,
		state: N,
		setTriggerId: L,
		triggerId: F
	}), [
		E,
		N,
		L,
		F
	]), B = a("div", e, {
		state: N,
		ref: _,
		props: f,
		stateAttributesMapping: H
	});
	return /*#__PURE__*/ j(g.Provider, {
		value: M,
		children: /*#__PURE__*/ j(z.Provider, {
			value: R,
			children: B
		})
	});
});
process.env.NODE_ENV !== "production" && (U.displayName = "AccordionItem");
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/accordion/header/AccordionHeader.js
var W = /*#__PURE__*/ A.forwardRef(function(e, t) {
	let { render: n, className: r, style: i, ...o } = e, { state: s } = B();
	return a("h3", e, {
		state: s,
		ref: t,
		props: o,
		stateAttributesMapping: H
	});
});
process.env.NODE_ENV !== "production" && (W.displayName = "AccordionHeader");
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/accordion/trigger/AccordionTrigger.js
function G(e) {
	let { current: t } = e, n = [];
	for (let e = 0; e < t.length; e += 1) {
		let r = t[e];
		if (!x(r)) {
			let e = r?.querySelector("[type=\"button\"], [role=\"button\"]");
			e && !x(e) && n.push(e);
		}
	}
	return n;
}
var K = /*#__PURE__*/ A.forwardRef(function(e, n) {
	let { disabled: r, className: i, id: o, render: s, nativeButton: c = !0, style: l, ...u } = e, { panelId: d, open: f, handleTrigger: p, disabled: m } = h(), { getButtonProps: g, buttonRef: _ } = S({
		disabled: r ?? m,
		focusableWhenDisabled: !0,
		native: c,
		composite: !0
	}), { accordionItemRefs: v, direction: b, loopFocus: x, orientation: k } = I(), A = b === "rtl", j = k === "horizontal", { state: M, setTriggerId: N, triggerId: P } = B();
	return t(() => (o && N(o), () => {
		N(void 0);
	}), [o, N]), a("button", e, {
		state: M,
		ref: [n, _],
		props: [
			{
				"aria-controls": f ? d : void 0,
				"aria-expanded": f,
				id: P,
				tabIndex: 0,
				onClick: p,
				onKeyDown(e) {
					if (!E.has(e.key)) return;
					C(e);
					let t = G(v), n = t.length - 1, r = -1, i = t.indexOf(e.currentTarget);
					function a() {
						r = x ? i + 1 > n ? 0 : i + 1 : Math.min(i + 1, n);
					}
					function o() {
						r = x && i === 0 ? n : i - 1;
					}
					switch (e.key) {
						case O:
							j || a();
							break;
						case w:
							j || o();
							break;
						case T:
							j && (A ? o() : a());
							break;
						case D:
							j && (A ? a() : o());
							break;
						case "Home":
							r = 0;
							break;
						case "End":
							r = n;
							break;
						default: break;
					}
					r > -1 && t[r].focus();
				}
			},
			u,
			g
		],
		stateAttributesMapping: y
	});
});
process.env.NODE_ENV !== "production" && (K.displayName = "AccordionTrigger");
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/accordion/panel/AccordionPanelCssVars.js
var q = /*#__PURE__*/ function(e) {
	return e.accordionPanelHeight = "--accordion-panel-height", e.accordionPanelWidth = "--accordion-panel-width", e;
}({}), J = /*#__PURE__*/ A.forwardRef(function(e, i) {
	let { className: o, hiddenUntilFound: s, keepMounted: c, id: l, render: u, style: d, ...f } = e, { hiddenUntilFound: p, keepMounted: m } = I(), { mounted: g, onOpenChange: _, open: v, panelId: y, setMounted: x, setOpen: S, setPanelIdState: C, transitionStatus: w } = h(), T = s ?? p, E = c ?? m;
	process.env.NODE_ENV !== "production" && t(() => {
		c === !1 && T && n("The `keepMounted={false}` prop on an `Accordion.Panel` is ignored when `hiddenUntilFound` is enabled on the panel or root, since the panel must remain mounted while closed.");
	}, [T, c]), t(() => {
		if (l) return C(l), () => {
			C(void 0);
		};
	}, [l, C]);
	let { height: D, props: O, ref: k, shouldPreventOpenAnimation: A, shouldRender: j, transitionStatus: M, width: N } = b({
		externalRef: i,
		hiddenUntilFound: T,
		id: l ?? y,
		keepMounted: E,
		mounted: g,
		onOpenChange: _,
		open: v,
		setMounted: x,
		setOpen: S,
		transitionStatus: w
	}), { state: P, triggerId: F } = B(), L = {
		...P,
		transitionStatus: M
	}, R = r(d, L), z = a("div", {
		...e,
		style: void 0
	}, {
		state: L,
		ref: k,
		props: [
			O,
			{
				"aria-labelledby": F,
				role: "region",
				style: {
					[q.accordionPanelHeight]: D === void 0 ? "auto" : `${D}px`,
					[q.accordionPanelWidth]: N === void 0 ? "auto" : `${N}px`
				}
			},
			f,
			R ? { style: R } : void 0,
			A ? { style: { animationName: "none" } } : void 0
		],
		stateAttributesMapping: H
	});
	return j ? z : null;
});
process.env.NODE_ENV !== "production" && (J.displayName = "AccordionPanel");
//#endregion
//#region lib/components/ui/atoms/accordion.tsx
function Y({ className: e, type: t, multiple: n, collapsible: r, ...i }) {
	return /* @__PURE__ */ j(R, {
		className: k("flex w-full flex-col", e),
		"data-slot": "accordion",
		multiple: n ?? t === "multiple",
		...i
	});
}
function X({ className: e, ...t }) {
	return /* @__PURE__ */ j(U, {
		className: k("not-last:border-b", e),
		"data-slot": "accordion-item",
		...t
	});
}
function Z({ className: e, children: t, ...n }) {
	return /* @__PURE__ */ j(W, {
		className: "flex",
		children: /* @__PURE__ */ M(K, {
			className: k("group/accordion-trigger relative flex flex-1 items-start justify-between rounded-lg border border-transparent py-2.5 text-left font-medium text-sm outline-none transition-all hover:underline focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:after:border-ring aria-disabled:pointer-events-none aria-disabled:opacity-50 **:data-[slot=accordion-trigger-icon]:ml-auto **:data-[slot=accordion-trigger-icon]:size-4 **:data-[slot=accordion-trigger-icon]:text-muted-foreground", e),
			"data-slot": "accordion-trigger",
			...n,
			children: [
				t,
				/* @__PURE__ */ j(N, {
					className: "pointer-events-none shrink-0 group-aria-expanded/accordion-trigger:hidden",
					"data-slot": "accordion-trigger-icon"
				}),
				/* @__PURE__ */ j(P, {
					className: "pointer-events-none hidden shrink-0 group-aria-expanded/accordion-trigger:inline",
					"data-slot": "accordion-trigger-icon"
				})
			]
		})
	});
}
function Q({ className: e, children: t, ...n }) {
	return /* @__PURE__ */ j(J, {
		className: "overflow-hidden text-sm data-closed:animate-accordion-up data-open:animate-accordion-down",
		"data-slot": "accordion-content",
		...n,
		children: /* @__PURE__ */ j("div", {
			className: k("h-(--accordion-panel-height) pt-0 pb-2.5 data-ending-style:h-0 data-starting-style:h-0 [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground [&_p:not(:last-child)]:mb-4", e),
			children: t
		})
	});
}
//#endregion
export { Z as i, Q as n, X as r, Y as t };
