import { a as D, l as A, v as u } from "./vendor-preact-DThS2ZQ_.js";
import { n as cn } from "./loadingIcon-B0ysgiNq.js";
import { m as CalendarIcon } from "./icons-CJJbIpBq.js";
import { t as InputComposed } from "./inputComposed-C1R2LAa3.js";
import "./inputComposed-BaY5q9WM.js";
//#region src/shared/dateInputComposed/dateInputComposed.tsx
var DateInputComposed = D(({ id, label, disabled, class: className, onInput, onBlur, ...restProps }, ref) => {
	const tryShowPicker = (input) => {
		if (!input) return false;
		if (!("showPicker" in HTMLInputElement.prototype)) return false;
		try {
			input.showPicker();
			return true;
		} catch {
			return false;
		}
	};
	const handleClick = (e) => {
		if (disabled) {
			e.preventDefault();
			return;
		}
		const input = e.currentTarget.control;
		tryShowPicker(input);
	};
	const valueJustChanged = A(false);
	const handleInput = (e) => {
		onInput(e);
		valueJustChanged.current = true;
	};
	const handleBlur = (e) => {
		onBlur?.(e);
		if (!valueJustChanged.current) return;
		valueJustChanged.current = false;
		if (e.relatedTarget !== null) return;
		const input = e.currentTarget;
		if (!input) return;
		requestAnimationFrame(() => {
			const active = document.activeElement;
			if (active === null || active === document.body) input.focus();
		});
	};
	return /* @__PURE__ */ u(InputComposed, {
		ref,
		id,
		type: "date",
		label,
		disabled,
		class: cn("IncodeDateInputComposed", className),
		onInput: handleInput,
		onBlur: handleBlur,
		rightIcon: /* @__PURE__ */ u("label", {
			htmlFor: id,
			class: "IncodeDateInputComposedIconButton",
			"aria-hidden": "true",
			tabIndex: -1,
			"data-disabled": disabled ? "true" : void 0,
			onClick: handleClick,
			children: /* @__PURE__ */ u("span", {
				class: "IncodeDateInputComposedIcon",
				children: /* @__PURE__ */ u(CalendarIcon, {})
			})
		}),
		...restProps
	});
});
DateInputComposed.displayName = "DateInputComposed";
//#endregion
export { DateInputComposed as t };
