"use client";
import { t as e } from "./useControlled-ZBScq72P.js";
import { t } from "./useIsoLayoutEffect-CKOv1bV_.js";
import { l as n, o as r, r as i, t as a, u as o } from "./useRenderElement-CmuWsiNa.js";
import { g as s, t as ee } from "./createBaseUIEventDetails-ChcQXp54.js";
import { t as c } from "./useBaseUiId-DOm5ACje.js";
import { l } from "./floating-ui.utils.dom-5U5b4xPf.js";
import { t as u } from "./useButton-AXffhTAZ.js";
import { cn as d } from "./lib/utils.js";
import { n as te, t as ne } from "./visuallyHidden-CEAV1xeA.js";
import { t as re } from "./useValueChanged-j5e75XB6.js";
import { i as f, n as ie, r as ae, t as p } from "./LabelableContext-Q1Z-xUI9.js";
import { t as m } from "./FormContext-4NSsO4w6.js";
import { t as h } from "./useAriaLabelledBy-DKl6aNOD.js";
import { t as g } from "./useLabelableId-Dgoo7-Ly.js";
import * as _ from "react";
import { jsx as v, jsxs as y } from "react/jsx-runtime";
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/switch/root/SwitchRootContext.js
var b = /*#__PURE__*/ _.createContext(void 0);
process.env.NODE_ENV !== "production" && (b.displayName = "SwitchRootContext");
function oe() {
	let e = _.useContext(b);
	if (e === void 0) throw Error(process.env.NODE_ENV === "production" ? o(63) : "Base UI: SwitchRootContext is missing. Switch parts must be placed within <Switch.Root>.");
	return e;
}
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/switch/root/SwitchRootDataAttributes.js
var x = /*#__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;
}({}), S = {
	...f,
	checked(e) {
		return e ? { [x.checked]: "" } : { [x.unchecked]: "" };
	}
}, C = /*#__PURE__*/ _.forwardRef(function(o, d) {
	let { checked: f, className: oe, defaultChecked: x, "aria-labelledby": C, form: w, id: T, inputRef: se, name: ce, nativeButton: E = !1, onCheckedChange: le, readOnly: D = !1, required: O = !1, disabled: k = !1, render: ue, uncheckedValue: A, value: j, style: de, ...M } = o, { clearErrors: N } = m(), { state: P, setTouched: F, setDirty: I, validityData: L, setFilled: R, setFocused: z, shouldValidateOnChange: B, validationMode: fe, disabled: V, name: H, validation: U } = ae(), { labelId: pe } = p(), W = V || k, G = H ?? ce, K = _.useRef(null), me = n(K, se, U.inputRef), q = _.useRef(null), J = c(), Y = g({
		id: T,
		implicit: !1,
		controlRef: q
	}), X = E ? void 0 : Y, [Z, he] = e({
		controlled: f,
		default: !!x,
		name: "Switch",
		state: "checked"
	});
	ie(q, J, Z), t(() => {
		K.current && R(K.current.checked);
	}, [K, R]), re(Z, () => {
		N(G), I(Z !== L.initialValue), R(Z), B() ? U.commit(Z) : U.commit(Z, !0);
	});
	let { getButtonProps: ge, buttonRef: _e } = u({
		disabled: W,
		native: E
	}), Q = h(C, pe, K, !E, X), ve = {
		id: E ? Y : J,
		role: "switch",
		"aria-checked": Z,
		"aria-readonly": D || void 0,
		"aria-required": O || void 0,
		"aria-labelledby": Q,
		onFocus() {
			W || z(!0);
		},
		onBlur() {
			let e = K.current;
			!e || W || (F(!0), z(!1), fe === "onBlur" && U.commit(e.checked));
		},
		onClick(e) {
			if (D || W) return;
			e.preventDefault();
			let t = K.current;
			t && t.dispatchEvent(new (l(t)).PointerEvent("click", {
				bubbles: !0,
				shiftKey: e.shiftKey,
				ctrlKey: e.ctrlKey,
				altKey: e.altKey,
				metaKey: e.metaKey
			}));
		}
	}, ye = i({
		checked: Z,
		disabled: W,
		form: w,
		id: X,
		name: G,
		required: O,
		style: G ? te : ne,
		tabIndex: -1,
		type: "checkbox",
		"aria-hidden": !0,
		ref: me,
		onChange(e) {
			if (e.nativeEvent.defaultPrevented) return;
			if (D) {
				e.preventDefault();
				return;
			}
			let t = e.currentTarget.checked, n = ee(s, e.nativeEvent);
			le?.(t, n), !n.isCanceled && he(t);
		},
		onFocus() {
			q.current?.focus();
		}
	}, U.getInputValidationProps, j === void 0 ? r : { value: j }), $ = _.useMemo(() => ({
		...P,
		checked: Z,
		disabled: W,
		readOnly: D,
		required: O
	}), [
		P,
		Z,
		W,
		D,
		O
	]), be = a("span", o, {
		state: $,
		ref: [
			d,
			q,
			_e
		],
		props: [
			ve,
			U.getValidationProps,
			M,
			ge
		],
		stateAttributesMapping: S
	});
	return /*#__PURE__*/ y(b.Provider, {
		value: $,
		children: [
			be,
			!Z && G && A !== void 0 && /*#__PURE__*/ v("input", {
				type: "hidden",
				form: w,
				name: G,
				value: A
			}),
			/*#__PURE__*/ v("input", {
				...ye,
				suppressHydrationWarning: !0
			})
		]
	});
});
process.env.NODE_ENV !== "production" && (C.displayName = "SwitchRoot");
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/switch/thumb/SwitchThumb.js
var w = /*#__PURE__*/ _.forwardRef(function(e, t) {
	let { render: n, className: r, style: i, ...o } = e;
	return a("span", e, {
		state: oe(),
		ref: t,
		stateAttributesMapping: S,
		props: o
	});
});
process.env.NODE_ENV !== "production" && (w.displayName = "SwitchThumb");
//#endregion
//#region lib/components/ui/atoms/switch.tsx
function T({ className: e, size: t = "default", loading: n = !1, loadingIndicatorClassName: r, disabled: i, ...a }) {
	return /* @__PURE__ */ y(C, {
		"aria-busy": n || void 0,
		className: d("peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-foreground/10 outline-none transition-all after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-[18.4px] data-[size=sm]:h-[14px] data-[size=default]:w-[32px] data-[size=sm]:w-[24px] data-disabled:cursor-not-allowed data-checked:bg-primary data-unchecked:bg-input data-disabled:opacity-50 dark:border-transparent dark:data-unchecked:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40", e),
		"data-loading": n || void 0,
		"data-size": t,
		"data-slot": "switch",
		disabled: i || n,
		...a,
		children: [/* @__PURE__ */ v(w, {
			className: d("pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-unchecked:translate-x-0 dark:data-checked:bg-primary-foreground dark:data-unchecked:bg-foreground", n && "opacity-0"),
			"data-slot": "switch-thumb"
		}), n && /* @__PURE__ */ v("span", {
			"aria-hidden": "true",
			className: "pointer-events-none absolute inset-0 flex items-center justify-center",
			children: /* @__PURE__ */ v("span", { className: d("animate-spin rounded-full border-2 border-muted-foreground border-t-transparent group-data-[size=default]/switch:size-3 group-data-[size=sm]/switch:size-2.5", r) })
		})]
	});
}
//#endregion
export { T as t };
