require("../../../_virtual/_rolldown/runtime.js");
let react = require("react");
//#region src/components/ticketBooking/hooks/useNetworkStatus.ts
let NetworkStatus = /* @__PURE__ */ function(NetworkStatus) {
	NetworkStatus["GOOD"] = "GOOD";
	NetworkStatus["WEAK"] = "WEAK";
	NetworkStatus["OFFLINE"] = "OFFLINE";
	return NetworkStatus;
}({});
const NetworkStatusColor = {
	[NetworkStatus.GOOD]: "#3F9E4D",
	[NetworkStatus.WEAK]: "#CC8E50",
	[NetworkStatus.OFFLINE]: "#F44336"
};
const useNetworkStatus = () => {
	const [status, setStatus] = (0, react.useState)(navigator.onLine ? NetworkStatus.GOOD : NetworkStatus.OFFLINE);
	(0, react.useEffect)(() => {
		const checkNetworkQuality = () => {
			if (!navigator.onLine) {
				setStatus(NetworkStatus.OFFLINE);
				return;
			}
			const connection = navigator.connection;
			if (connection) setStatus(connection.effectiveType === "2g" || connection.effectiveType === "slow-2g" || connection.rtt > 500 || connection.downlink < 1 ? NetworkStatus.WEAK : NetworkStatus.GOOD);
		};
		window.addEventListener("online", checkNetworkQuality);
		window.addEventListener("offline", checkNetworkQuality);
		const connection = navigator.connection;
		if (connection) connection.addEventListener("change", checkNetworkQuality);
		checkNetworkQuality();
		return () => {
			window.removeEventListener("online", checkNetworkQuality);
			window.removeEventListener("offline", checkNetworkQuality);
			if (connection) connection.removeEventListener("change", checkNetworkQuality);
		};
	}, []);
	return status;
};
//#endregion
exports.NetworkStatus = NetworkStatus;
exports.NetworkStatusColor = NetworkStatusColor;
exports.useNetworkStatus = useNetworkStatus;
