"use client";
import { useEffect } from "react";
import { triggerManualChangeEvent } from "./utils.js";
/**
 * @since 6.0.0
 * @internal
 */ export function useFormReset(options) {
    const { form, elementRef, defaultValue } = options;
    useEffect(()=>{
        const element = elementRef.current;
        if (!element) {
            return;
        }
        const formElement = form && document.getElementById(form) || element.closest("form") || null;
        if (!formElement) {
            return;
        }
        const handleReset = ()=>{
            triggerManualChangeEvent(element, defaultValue);
        };
        formElement.addEventListener("reset", handleReset);
        return ()=>{
            formElement.removeEventListener("reset", handleReset);
        };
    }, [
        defaultValue,
        elementRef,
        form
    ]);
}

//# sourceMappingURL=useFormReset.js.map