import { useAuthedUser } from "../../utilities/auth/useAuthedUser.mjs";
import { getLocalizedDateString, getLocalizedDateTimeString } from "../../UI/widgets/utils/dateUtils.mjs";
import { c } from "react-compiler-runtime";
import "react";
import { IANAZone } from "luxon";
//#region src/udp/utilities/dateLocalizationHooks.jsx
/**
* Gets a function that can be used to convert a date or
* ISO 8601 date string (EX: yyyy-MM-ddThh:mm:ss[Z|offset])
* to a localized date string without time in the specified IANA time zone.
* @param timeZone An IANA time zone to convert the date to before returning as a string.
* @returns A function to convert a date to a localized string.
*/
const useGetLocalizedDateString = (timeZone) => {
	const $ = c(3);
	const user = useAuthedUser();
	let t0;
	if ($[0] !== timeZone || $[1] !== user?.additionalProperties?.activeUtilityTimeZone) {
		t0 = (date) => {
			return getLocalizedDateString(date, timeZone !== "local" && (timeZone === user?.additionalProperties?.activeUtilityTimeZone || IANAZone.isValidZone(timeZone)) ? timeZone : "local");
		};
		$[0] = timeZone;
		$[1] = user?.additionalProperties?.activeUtilityTimeZone;
		$[2] = t0;
	} else t0 = $[2];
	return t0;
};
/**
* Gets a function that can be used to convert a date or
* ISO 8601 date string (EX: yyyy-MM-ddThh:mm:ss[Z|offset])
* to a localized date time string in the specified IANA time zone.
* @param timeZone The IANA time zone to convert the date before converting to
* a localized string.
* @param includeTimeZoneOffset If true, include the time zone offset in the localized string.
* @returns A function to convert a date to a localized string.
*/
const useGetLocalizedDateTimeString = (timeZone, t0) => {
	const $ = c(4);
	const includeTimeZoneOffset = t0 === void 0 ? false : t0;
	const user = useAuthedUser();
	let t1;
	if ($[0] !== includeTimeZoneOffset || $[1] !== timeZone || $[2] !== user?.additionalProperties?.activeUtilityTimeZone) {
		t1 = (date, t2) => {
			return getLocalizedDateTimeString(date, t2 === void 0 ? null : t2, timeZone !== "local" && (timeZone === user?.additionalProperties?.activeUtilityTimeZone || IANAZone.isValidZone(timeZone)) ? timeZone : "local", includeTimeZoneOffset);
		};
		$[0] = includeTimeZoneOffset;
		$[1] = timeZone;
		$[2] = user?.additionalProperties?.activeUtilityTimeZone;
		$[3] = t1;
	} else t1 = $[3];
	return t1;
};
/**
* Gets a function that can be used to convert a date or
* ISO 8601 date string (EX: yyyy-MM-ddThh:mm:ss[Z|offset])
* to a localized date time string in the current user's time zone.
* @param includeTimeZoneOffset If true, include the time zone offset in the localized string.
* @returns A function to convert a date to a localized string.
*/
const useGetLocalizedUserDateTimeString = (t0) => {
	const $ = c(3);
	const includeTimeZoneOffset = t0 === void 0 ? false : t0;
	const user = useAuthedUser();
	let t1;
	if ($[0] !== includeTimeZoneOffset || $[1] !== user?.additionalProperties?.timeZone) {
		t1 = (date, t2) => {
			return getLocalizedDateTimeString(date, t2 === void 0 ? null : t2, user?.additionalProperties?.timeZone, includeTimeZoneOffset);
		};
		$[0] = includeTimeZoneOffset;
		$[1] = user?.additionalProperties?.timeZone;
		$[2] = t1;
	} else t1 = $[2];
	return t1;
};
//#endregion
export { useGetLocalizedDateString, useGetLocalizedDateTimeString, useGetLocalizedUserDateTimeString };

//# sourceMappingURL=dateLocalizationHooks.mjs.map