/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
let react = require("react");

//#region src/hooks/useRtl.ts
/**
* Gets the current RTL state from document direction
*/
const getDocumentDirection = () => {
	if (typeof document === "undefined") return false;
	return getComputedStyle(document.documentElement).direction === "rtl";
};
/**
* Creates a mutation observer to watch for direction changes
*/
const createDirectionObserver = (callback) => {
	const observer = new MutationObserver((mutations) => {
		if (mutations.some((mutation) => mutation.type === "attributes" && mutation.attributeName === "dir")) callback();
	});
	observer.observe(document.documentElement, {
		attributes: true,
		attributeFilter: ["dir"]
	});
	return observer;
};
/**
* Hook to detect RTL context from document direction or explicit override
* @default reads from document direction
*/
const useRtl = (options) => {
	const [isRtl, setIsRtl] = (0, react.useState)(getDocumentDirection);
	(0, react.useEffect)(() => {
		if (options?.explicit) {
			setIsRtl(options.explicit);
			return;
		}
		const observer = createDirectionObserver(() => {
			setIsRtl(getDocumentDirection());
		});
		return () => observer.disconnect();
	}, [options?.explicit]);
	return isRtl;
};

//#endregion
exports.createDirectionObserver = createDirectionObserver;
exports.getDocumentDirection = getDocumentDirection;
exports.useRtl = useRtl;