import { useState, useEffect } from "react";
import { getDeviceTransactionConfig, } from "../transaction/deviceTransactionConfig";
/**
 * Hook to fetch device transaction configuration fields asynchronously.
 * This anticipates the future async nature of crypto assets store operations.
 */
export function useDeviceTransactionConfig({ account, parentAccount, transaction, status, }) {
    const [fields, setFields] = useState([]);
    const [loading, setLoading] = useState(true);
    useEffect(() => {
        let mounted = true;
        async function loadFields() {
            try {
                setLoading(true);
                const result = await getDeviceTransactionConfig({
                    account,
                    parentAccount,
                    transaction,
                    status,
                });
                if (mounted) {
                    setFields(result);
                    setLoading(false);
                }
            }
            catch (error) {
                console.error("Failed to load device transaction config:", error);
                if (mounted) {
                    setFields([]);
                    setLoading(false);
                }
            }
        }
        loadFields();
        return () => {
            mounted = false;
        };
    }, [account, parentAccount, transaction, status]);
    return { fields, loading };
}
//# sourceMappingURL=useDeviceTransactionConfig.js.map