//#region src/focus/focusable.ts
var e = "[data-initial-focus], [autofocus]", t = [
	"input:not([type=\"hidden\"]):not([type=\"button\"]):not([type=\"submit\"]):not([type=\"reset\"]):not([type=\"file\"]):not([disabled])",
	"textarea:not([disabled])",
	"[contenteditable=\"true\"]"
].join(","), n = [
	"select:not([disabled])",
	"button:not([disabled])",
	"input[type=\"checkbox\"]:not([disabled])",
	"input[type=\"radio\"]:not([disabled])"
].join(","), r = [
	"a[href]",
	"button:not([disabled])",
	"input:not([disabled])",
	"select:not([disabled])",
	"textarea:not([disabled])",
	"[tabindex]:not([tabindex=\"-1\"])",
	"[contenteditable=\"true\"]"
].join(","), i = (e) => e.closest("[hidden], [aria-hidden=\"true\"]") != null, a = (e) => e.getAttribute("aria-disabled") === "true" || "disabled" in e && e.disabled === !0, o = (e) => {
	if (e.hidden === !0) return !1;
	if (e.getClientRects().length > 0) return !0;
	let t = globalThis.getComputedStyle(e);
	return t.display !== "none" && t.visibility !== "hidden";
}, s = (e) => !(e instanceof HTMLElement) || !e.isConnected || a(e) || i(e) ? !1 : o(e), c = (e, t) => Array.from(e.querySelectorAll(t)).find(s) ?? null, l = (r) => c(r, e) ?? c(r, t) ?? c(r, n), u = (e) => e.matches(r) && s(e) ? e : c(e, r), d = (e) => {
	let t = Array.from(e.querySelectorAll(r)).filter(s);
	return e.matches(r) && s(e) ? [e, ...t] : t;
}, f = (e, t) => {
	switch (t) {
		case "first-form-control": return l(e);
		case "first-focusable": return u(e);
		case "dialog": return e;
		case "none": return null;
		default: return null;
	}
}, p = (e, t) => {
	if (typeof t == "string") return f(e, t);
	if (t.mode === "ref") return s(t.ref.current) ? t.ref.current : f(e, t.fallback ?? "dialog");
	let n = e.querySelector(t.selector);
	return s(n) ? n : f(e, t.fallback ?? "dialog");
}, m = (e, t) => t === "none" ? null : t === "first-form-control" ? l(e) : s(t.ref.current) ? t.ref.current : t.fallback === "first-form-control" ? l(e) : null, h = (e) => {
	e?.focus({ preventScroll: !0 });
};
//#endregion
export { u as findFirstFocusable, l as findFirstFormControl, h as focusElement, d as getFocusableElements, s as isFocusableElement, m as resolveFormInitialFocusTarget, p as resolveInitialFocusTarget };

//# sourceMappingURL=focusable.js.map