"use client";
import { t as e } from "./useControlled-ZBScq72P.js";
import { t } from "./useIsoLayoutEffect-CKOv1bV_.js";
import { l as ee, o as n, s as r, t as i, u as a } from "./useRenderElement-CmuWsiNa.js";
import { t as o } from "./useStableCallback-CqEVb76s.js";
import { g as s, t as c } from "./createBaseUIEventDetails-ChcQXp54.js";
import { t as l } from "./useBaseUiId-DOm5ACje.js";
import { a as u, o as d, t as f } from "./useOpenChangeComplete-DjMFUwhi.js";
import { l as te } from "./floating-ui.utils.dom-5U5b4xPf.js";
import { t as p } from "./useButton-AXffhTAZ.js";
import { n as m } from "./shadowDom-C-4Ejp9R.js";
import { p as h } from "./composite-BlDfbDkL.js";
import { cn as g } from "./lib/utils.js";
import { n as _, t as v } from "./visuallyHidden-CEAV1xeA.js";
import { t as y } from "./useValueChanged-j5e75XB6.js";
import { i as ne, n as b, r as re, t as ie } from "./LabelableContext-Q1Z-xUI9.js";
import { t as x } from "./FieldItemContext-4qBxodsW.js";
import { t as ae } from "./FormContext-4NSsO4w6.js";
import { t as oe } from "./useAriaLabelledBy-DKl6aNOD.js";
import { t as se } from "./CompositeItem-BWqRobLN.js";
import { t as ce } from "./useLabelableId-Dgoo7-Ly.js";
import { n as le, t as ue } from "./CompositeRoot-BIh8l7ys.js";
import { t as S } from "./serializeValue-kHY7UUsW.js";
import * as C from "react";
import { jsx as w, jsxs as T } from "react/jsx-runtime";
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/fieldset/root/FieldsetRootContext.js
var E = /*#__PURE__*/ C.createContext({
	legendId: void 0,
	setLegendId: () => {},
	disabled: void 0
});
process.env.NODE_ENV !== "production" && (E.displayName = "FieldsetRootContext");
function D(e = !1) {
	let t = C.useContext(E);
	if (!t && !e) throw Error(process.env.NODE_ENV === "production" ? a(86) : "Base UI: FieldsetRootContext is missing. Fieldset parts must be placed within <Fieldset.Root>.");
	return t;
}
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/radio/root/RadioRootDataAttributes.js
var O = /*#__PURE__*/ function(e) {
	return e.checked = "data-checked", e.unchecked = "data-unchecked", e.disabled = "data-disabled", e.readonly = "data-readonly", e.required = "data-required", e.valid = "data-valid", e.invalid = "data-invalid", e.touched = "data-touched", e.dirty = "data-dirty", e.filled = "data-filled", e.focused = "data-focused", e;
}({}), k = {
	checked(e) {
		return e ? { [O.checked]: "" } : { [O.unchecked]: "" };
	},
	...u,
	...ne
}, A = /*#__PURE__*/ C.createContext(void 0);
process.env.NODE_ENV !== "production" && (A.displayName = "RadioGroupContext");
function de() {
	return C.useContext(A);
}
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/radio/root/RadioRootContext.js
var j = /*#__PURE__*/ C.createContext(void 0);
process.env.NODE_ENV !== "production" && (j.displayName = "RadioRootContext");
function M() {
	let e = C.useContext(j);
	if (e === void 0) throw Error(process.env.NODE_ENV === "production" ? a(52) : "Base UI: RadioRootContext is missing. Radio parts must be placed within <Radio.Root>.");
	return e;
}
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/radio/root/RadioRoot.js
var N = /*#__PURE__*/ C.forwardRef(function(e, a) {
	let { render: u, className: d, disabled: f = !1, readOnly: m = !1, required: h = !1, "aria-labelledby": g, value: y, inputRef: ne, nativeButton: b = !1, id: ae, style: ue, ...E } = e, D = de(), { disabled: O, readOnly: A, required: M, form: N, checkedValue: P, touched: fe = !1, validation: F, name: I } = D ?? {}, L = D?.setCheckedValue ?? r, R = D?.setTouched ?? r, z = D?.registerControlRef ?? r, B = D?.registerInputRef ?? r, { setDirty: V, validityData: H, setTouched: U, setFilled: W, state: G, disabled: K } = re(), pe = x(), { labelId: me, getDescriptionProps: he } = ie(), q = K || pe.disabled || O || f, J = A || m, Y = M || h, ge = N, X = D ? P === y : y === "", Z = C.useRef(null), Q = C.useRef(null), _e = o((e) => {
		e && z(e, q);
	}), ve = ee(ne, Q, B);
	t(() => {
		Q.current?.checked && W(!0);
	}, [W]), t(() => {
		if (Q.current) {
			if (q && X) {
				B(null);
				return;
			}
			Z.current && z(Z.current, q), B(Q.current);
		}
	}, [
		X,
		q,
		z,
		B
	]);
	let ye = l(), be = ce({
		id: ae,
		implicit: !1,
		controlRef: Z
	}), xe = b ? void 0 : be, Se = oe(g, me, Q, !b, xe), Ce = {
		role: "radio",
		"aria-checked": X,
		"aria-required": Y || void 0,
		"aria-readonly": J || void 0,
		"aria-labelledby": Se,
		[le]: X ? "" : void 0,
		id: b ? be : ye,
		onKeyDown(e) {
			e.key === "Enter" && e.preventDefault();
		},
		onClick(e) {
			if (e.defaultPrevented || q || J) return;
			e.preventDefault();
			let t = Q.current;
			t && t.dispatchEvent(new (te(t)).PointerEvent("click", {
				bubbles: !0,
				shiftKey: e.shiftKey,
				ctrlKey: e.ctrlKey,
				altKey: e.altKey,
				metaKey: e.metaKey
			}));
		},
		onFocus(e) {
			e.defaultPrevented || q || J || !fe || (Q.current?.click(), R(!1));
		}
	}, { getButtonProps: we, buttonRef: Te } = p({
		disabled: q,
		native: b
	}), Ee = {
		type: "radio",
		ref: ve,
		form: ge,
		id: xe,
		name: I,
		tabIndex: -1,
		style: I ? _ : v,
		"aria-hidden": !0,
		...y === void 0 ? n : { value: S(y) },
		disabled: q,
		checked: X,
		required: Y,
		readOnly: J,
		onChange(e) {
			if (e.nativeEvent.defaultPrevented || q || J || y === void 0) return;
			let t = c(s, e.nativeEvent);
			t.isCanceled || (U(!0), V(y !== H.initialValue), W(!0), L(y, t));
		},
		onFocus() {
			Z.current?.focus();
		}
	}, $ = C.useMemo(() => ({
		...G,
		required: Y,
		disabled: q,
		readOnly: J,
		checked: X
	}), [
		G,
		q,
		J,
		X,
		Y
	]), De = $, Oe = D !== void 0, ke = [
		a,
		Z,
		Te,
		_e
	], Ae = [
		Ce,
		he,
		F?.getValidationProps ?? n,
		E,
		we
	], je = i("span", e, {
		enabled: !Oe,
		state: $,
		ref: ke,
		props: Ae,
		stateAttributesMapping: k
	});
	return /*#__PURE__*/ T(j.Provider, {
		value: De,
		children: [Oe ? /*#__PURE__*/ w(se, {
			tag: "span",
			render: u,
			className: d,
			style: ue,
			state: $,
			refs: ke,
			props: Ae,
			stateAttributesMapping: k
		}) : je, /*#__PURE__*/ w("input", {
			...Ee,
			suppressHydrationWarning: !0
		})]
	});
});
process.env.NODE_ENV !== "production" && (N.displayName = "RadioRoot");
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/radio/indicator/RadioIndicator.js
var P = /*#__PURE__*/ C.forwardRef(function(e, t) {
	let { render: ee, className: n, style: r, keepMounted: a = !1, ...o } = e, s = M(), c = s.checked, { mounted: l, transitionStatus: u, setMounted: te } = d(c), p = {
		...s,
		transitionStatus: u
	}, m = C.useRef(null), h = a || l, g = i("span", e, {
		ref: [t, m],
		state: p,
		props: o,
		stateAttributesMapping: k
	});
	return f({
		open: c,
		ref: m,
		onComplete() {
			c || te(!1);
		}
	}), h ? g : null;
});
process.env.NODE_ENV !== "production" && (P.displayName = "RadioIndicator");
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/radio-group/RadioGroup.js
var fe = [h], F = /*#__PURE__*/ C.forwardRef(function(t, ee) {
	let { render: n, className: r, disabled: i, readOnly: a, required: s, onValueChange: c, value: u, defaultValue: d, form: f, name: te, inputRef: p, id: h, style: g, ..._ } = t, { setTouched: v, setFocused: x, shouldValidateOnChange: oe, validationMode: se, name: ce, disabled: le, state: S, validation: T, setDirty: E, setFilled: O, validityData: k } = re(), { labelId: de } = ie(), { clearErrors: j } = ae(), M = D(!0), N = le || i, P = ce ?? te, F = l(h), [I, L] = e({
		controlled: u,
		default: d,
		name: "RadioGroup",
		state: "value"
	}), [R, z] = C.useState(!1), B = o((e, t) => {
		c?.(e, t), !t.isCanceled && L(e);
	}), V = C.useRef(null), H = C.useRef(null), U = C.useRef(null);
	function W(e) {
		let t;
		return p && (typeof p == "function" ? t = p(e) : p.current = e), H.current = e, T.inputRef.current = e, t;
	}
	let G = o((e, t = !1) => {
		if (e) {
			if (t) {
				V.current === e && (V.current = null);
				return;
			}
			V.current ??= e;
		}
	}), K = o((e) => {
		if (!e || e.disabled) return;
		U.current ||= e;
		let t = H.current;
		if (e.checked || t == null || t.disabled) return W(e);
	});
	b(V, F, I ?? null), y(I, () => {
		j(P), E(I !== k.initialValue), O(I != null), oe() ? T.commit(I) : T.commit(I, !0);
		let e = U.current;
		I == null && e && !e.disabled && W(e);
	});
	let pe = _["aria-labelledby"] ?? de ?? M?.legendId, me = {
		...S,
		disabled: N ?? !1,
		required: s ?? !1,
		readOnly: a ?? !1
	}, he = C.useMemo(() => ({
		...S,
		checkedValue: I,
		disabled: N,
		form: f,
		validation: T,
		name: P,
		readOnly: a,
		registerControlRef: G,
		registerInputRef: K,
		required: s,
		setCheckedValue: B,
		setTouched: z,
		touched: R
	}), [
		I,
		N,
		f,
		T,
		S,
		P,
		a,
		G,
		K,
		s,
		B,
		z,
		R
	]), q = {
		role: "radiogroup",
		"aria-required": s || void 0,
		"aria-disabled": N || void 0,
		"aria-readonly": a || void 0,
		"aria-labelledby": pe,
		onFocus() {
			x(!0);
		},
		onBlur(e) {
			m(e.currentTarget, e.relatedTarget) || (v(!0), x(!1), se === "onBlur" && T.commit(I));
		},
		onKeyDownCapture(e) {
			e.key.startsWith("Arrow") && (v(!0), z(!0), x(!0));
		}
	};
	return /*#__PURE__*/ w(A.Provider, {
		value: he,
		children: /*#__PURE__*/ w(ue, {
			render: n,
			className: r,
			style: g,
			state: me,
			props: [
				q,
				T.getValidationProps,
				_
			],
			refs: [ee],
			stateAttributesMapping: ne,
			enableHomeAndEndKeys: !1,
			modifierKeys: fe
		})
	});
});
process.env.NODE_ENV !== "production" && (F.displayName = "RadioGroup");
//#endregion
//#region lib/components/ui/atoms/radio-group.tsx
function I({ className: e, ...t }) {
	return /* @__PURE__ */ w(F, {
		className: g("grid w-full gap-3", e),
		"data-slot": "radio-group",
		...t
	});
}
function L({ className: e, ...t }) {
	return /* @__PURE__ */ w(N, {
		className: g("group/radio-group-item peer relative flex aspect-square size-4 shrink-0 rounded-full border border-input outline-none after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary data-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40", e),
		"data-slot": "radio-group-item",
		...t,
		children: /* @__PURE__ */ w(P, {
			className: "flex size-4 items-center justify-center",
			"data-slot": "radio-group-indicator",
			children: /* @__PURE__ */ w("span", { className: "absolute top-1/2 left-1/2 size-2.5 -translate-x-1/2 -translate-y-1/2 rounded-full bg-primary shadow-[inset_0_1px_2px_rgba(0,0,0,0.2)]" })
		})
	});
}
//#endregion
export { L as n, I as t };
