/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-b67433b | Cube Dev Team */
import { useEffect, useState } from "react";

//#region src/utils/react/useIsDarwin.ts
/**
* useIsDarwin
* ----------
* @returns true  – if the browser is running on macOS / iOS
*          false – otherwise (Windows, Linux, Android…)
*
* • Safe to call during server-side rendering: it defaults to `true`
*   until it can really inspect the client.
* • Uses the modern UA-Client-Hints platform field where available,
*   then falls back to navigator.platform, then navigator.userAgent.
*/
function useIsDarwin(defaultValue = true) {
	const [isDarwin, setIsDarwin] = useState(defaultValue);
	useEffect(() => {
		if (typeof navigator === "undefined") return;
		const chPlatform = navigator.userAgentData?.platform;
		if (chPlatform) {
			setIsDarwin(/mac|iphone|ipad|ipod/i.test(chPlatform));
			return;
		}
		if (navigator.platform) {
			setIsDarwin(/mac|iphone|ipad|ipod/i.test(navigator.platform));
			return;
		}
		setIsDarwin(/mac|iphone|ipad|ipod/i.test(navigator.userAgent));
	}, []);
	return isDarwin;
}

//#endregion
export { useIsDarwin };
//# sourceMappingURL=useIsDarwin.js.map