"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.filterPlatformCurrencies = exports.filterPlatformAccounts = void 0;
const minimatch_1 = require("minimatch");
const helpers_1 = require("./helpers");
function filterPlatformAccounts(accounts, filters) {
    const filterCurrencyRegexes = filters.currencies
        ? filters.currencies.map(filter => (0, minimatch_1.makeRe)(filter))
        : null;
    return accounts.filter(account => {
        if (filterCurrencyRegexes &&
            !filterCurrencyRegexes.some(regex => account.currency.match(regex))) {
            return false;
        }
        return true;
    });
}
exports.filterPlatformAccounts = filterPlatformAccounts;
function filterPlatformCurrencies(currencies, filters) {
    const filterCurrencyRegexes = filters.currencies
        ? filters.currencies.map(filter => (0, minimatch_1.makeRe)(filter))
        : null;
    return currencies.filter(currency => {
        if (!filters.includeTokens && (0, helpers_1.isPlatformTokenCurrency)(currency)) {
            return false;
        }
        if (filterCurrencyRegexes && !filterCurrencyRegexes.some(regex => currency.id.match(regex))) {
            return false;
        }
        return true;
    });
}
exports.filterPlatformCurrencies = filterPlatformCurrencies;
//# sourceMappingURL=filters.js.map