"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SupplyActionResolver = exports.LinkActionResolver = exports.ActionResolver = void 0;
const symbol_sdk_1 = require("symbol-sdk");
const action_enum_1 = require("../models/action.enum");
const options_resolver_1 = require("../options-resolver");
const action_validator_1 = require("../validators/action.validator");
/**
 * Link action resolver
 */
class ActionResolver {
    /**
     * Resolves an action provided by the user.
     * @param {Options} options - Command options.
     * @param {string} altText - Alternative text.
     * @param {string} altKey - Alternative key.
     * @returns {Promise<number>}
     */
    async resolve(options, altText, altKey) {
        const choices = Object.keys(action_enum_1.ActionType)
            .filter((key) => Number.isNaN(parseFloat(key)))
            .map((string) => ({
            title: string,
            value: action_enum_1.ActionType[string],
        }));
        const value = +(await (0, options_resolver_1.OptionsChoiceResolver)(options, altKey ? altKey : 'action', altText ? altText : 'Select an action:', choices, 'select', new action_validator_1.ActionValidator()));
        return value;
    }
}
exports.ActionResolver = ActionResolver;
/**
 * Link action resolver
 */
class LinkActionResolver {
    /**
     * Resolves an action provided by the user.
     * @param {Options} options - Command options.
     * @param {string} altText - Alternative text.
     * @param {string} altKey - Alternative key.
     * @returns {Promise<number>}
     */
    async resolve(options, altText, altKey) {
        const choices = Object.keys(symbol_sdk_1.LinkAction)
            .filter((key) => Number.isNaN(parseFloat(key)))
            .map((string) => ({
            title: string,
            value: symbol_sdk_1.LinkAction[string],
        }));
        const value = +(await (0, options_resolver_1.OptionsChoiceResolver)(options, altKey ? altKey : 'action', altText ? altText : 'Select an action:', choices, 'select', new action_validator_1.LinkActionValidator()));
        return value;
    }
}
exports.LinkActionResolver = LinkActionResolver;
class SupplyActionResolver {
    /**
     * Resolves an action provided by the user.
     * @param {Options} options - Command options.
     * @param {string} altText - Alternative text.
     * @param {string} altKey - Alternative key.
     * @returns {Promise<number>}
     */
    async resolve(options, altText, altKey) {
        const choices = Object.keys(symbol_sdk_1.MosaicSupplyChangeAction)
            .filter((key) => Number.isNaN(parseFloat(key)))
            .map((string) => ({
            title: string,
            value: symbol_sdk_1.MosaicSupplyChangeAction[string],
        }));
        const value = +(await (0, options_resolver_1.OptionsChoiceResolver)(options, altKey ? altKey : 'action', altText ? altText : 'Select an action:', choices, 'select', new action_validator_1.MosaicSupplyChangeActionValidator()));
        return value;
    }
}
exports.SupplyActionResolver = SupplyActionResolver;
