"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const composeHooks_1 = require("../../utils/composeHooks");
const useLeftApyModule_1 = require("../hooks/modules/useLeftApyModule");
const useRightBalanceAsset_1 = require("../hooks/useRightBalanceAsset");
const useLeftMarketTrendModule_1 = require("../hooks/modules/useLeftMarketTrendModule");
const useRightMarketTrendModule_1 = require("../hooks/modules/useRightMarketTrendModule");
const getRightElement = (AssetConfigurationDeps) => (rightElement) => {
    switch (rightElement) {
        case "undefined":
            return undefined;
        case "marketTrend":
            return (currencies) => (0, useRightMarketTrendModule_1.useRightMarketTrendModule)({
                currencies,
                useBalanceDeps: AssetConfigurationDeps.useBalanceDeps,
                MarketPriceIndicator: AssetConfigurationDeps.MarketPriceIndicator,
            });
        case "balance":
        default:
            return (0, useRightBalanceAsset_1.createUseRightBalanceAsset)({
                useBalanceDeps: AssetConfigurationDeps.useBalanceDeps,
                balanceItem: AssetConfigurationDeps.balanceItem,
                assetsMap: AssetConfigurationDeps.assetsMap,
            });
    }
};
const getLeftElement = (AssetConfigurationDeps) => (leftElement) => {
    switch (leftElement) {
        case "apy":
            return (assets) => (0, useLeftApyModule_1.useLeftApyModule)(assets, AssetConfigurationDeps.ApyIndicator);
        case "marketTrend":
            return (assets) => (0, useLeftMarketTrendModule_1.useLeftMarketTrendModule)(assets, AssetConfigurationDeps.MarketPercentIndicator);
        case "undefined":
        default:
            return undefined;
    }
};
const createAssetConfigurationHook = deps => ({ assetsConfiguration }) => {
    const { rightElement, leftElement } = assetsConfiguration ?? {};
    const rightHook = getRightElement(deps)(rightElement);
    const leftHook = getLeftElement(deps)(leftElement);
    // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
    const hooks = [rightHook, leftHook].filter(Boolean);
    return (assets) => {
        const composedHook = (0, composeHooks_1.composeHooks)(...hooks);
        return composedHook(assets);
    };
};
exports.default = createAssetConfigurationHook;
//# sourceMappingURL=createAssetConfiguration.js.map