"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useCheckAccountWithFundsAction = void 0;
const react_redux_1 = require("react-redux");
const types_live_1 = require("@ledgerhq/types-live");
const react_1 = require("react");
const reducer_1 = require("../reducer");
function useCheckAccountWithFundsAction(completeAction) {
    const hubState = (0, react_redux_1.useSelector)(reducer_1.hubStateSelector);
    const isAssetTransferComplete = hubState.actionsCompleted?.[types_live_1.PostOnboardingActionId.assetsTransfer];
    const handleAccountsUpdate = (0, react_1.useCallback)((accounts) => {
        if (!isAssetTransferComplete) {
            const hasAccountsWithFunds = accounts.some(account => account?.balance.isGreaterThan(0));
            if (hasAccountsWithFunds)
                completeAction(types_live_1.PostOnboardingActionId.assetsTransfer);
        }
    }, [completeAction, isAssetTransferComplete]);
    return handleAccountsUpdate;
}
exports.useCheckAccountWithFundsAction = useCheckAccountWithFundsAction;
//# sourceMappingURL=useCheckAccountWithFundsAction.js.map