import { SWAP_DATA_CDN } from "@ledgerhq/ledger-cal-service";
import { getAccountCurrency, makeEmptyTokenAccount } from "../../../account";
import { getSwapProvider } from "../../providers/swap";
export const FILTER = {
    centralised: "centralised",
    decentralised: "decentralised",
    float: "float",
    fixed: "fixed",
};
export function getAccountTuplesForCurrency(currency, allAccounts, hideEmpty) {
    if (currency.type === "TokenCurrency") {
        return allAccounts
            .filter(account => account.currency.id === currency.parentCurrency.id)
            .map(account => ({
            account,
            subAccount: (account.subAccounts &&
                account.subAccounts.find((subAcc) => subAcc.type === "TokenAccount" && subAcc.token.id === currency.id)) ||
                makeEmptyTokenAccount(account, currency),
        }))
            .filter(a => (hideEmpty ? a.subAccount?.balance.gt(0) : true));
    }
    return allAccounts
        .filter(account => account.currency.id === currency.id)
        .map(account => ({
        account,
        subAccount: null,
    }))
        .filter(a => (hideEmpty ? a.account?.balance.gt(0) : true));
}
export const getAvailableAccountsById = (id, accounts) => accounts
    .filter(acc => getAccountCurrency(acc)?.id === id && !acc.disabled)
    .sort((a, b) => b.balance.minus(a.balance).toNumber());
export const isRegistrationRequired = async (provider) => {
    const { needsBearerToken, needsKYC } = await getSwapProvider(provider);
    return needsBearerToken || needsKYC;
};
export const getProviderName = (provider) => {
    const { displayName } = SWAP_DATA_CDN[provider] ?? { displayName: "" };
    return displayName;
};
export const getNoticeType = (provider) => {
    switch (provider) {
        case "cic":
            return { message: "provider", learnMore: false };
        case "changelly":
            return {
                message: "provider",
                learnMore: false,
            };
        default:
            return { message: "default", learnMore: true };
    }
};
//# sourceMappingURL=index.js.map