"use strict";
/* tslint:disable class-name */
Object.defineProperty(exports, "__esModule", { value: true });
const Rule_1 = require("../../../rules/Rule");
const rule_weight_schema_1 = require("./rules/rule-weight-schema");
const rule_tags_schema_1 = require("./rules/rule-tags-schema");
const rule_authors_schema_1 = require("./rules/rule-authors-schema");
const rule_voting_power_schema_1 = require("./rules/rule-voting-power-schema");
const rule_custom_rpc_schema_1 = require("./rules/rule-custom-rpc-schema");
const ValidationException_1 = require("../../../validation/ValidationException");
const rule_weight_for_period_schema_1 = require("./rules/rule-weight-for-period-schema");
const rule_votes_count_schema_1 = require("./rules/rule-votes-count-schema");
const rule_voters_schema_1 = require("./rules/rule-voters-schema");
const rule_first_post_schema_1 = require("./rules/rule-first-post-schema");
const rule_payout_schema_1 = require("./rules/rule-payout-schema");
const rule_expiration_date_1 = require("./rules/rule-expiration-date");
const rule_age_of_post_schema_1 = require("./rules/rule-age-of-post-schema");
exports.wise_rule_decode = (r) => {
    switch (r.rule) {
        case "weight":
            return rule_weight_schema_1.wise_rule_weight_decode(r);
        case "weight_for_period":
            return rule_weight_for_period_schema_1.wise_rule_weight_for_period_decode(r);
        case "tags":
            return rule_tags_schema_1.wise_rule_tags_decode(r);
        case "authors":
            return rule_authors_schema_1.wise_rule_authors_decode(r);
        case "voting_power":
            return rule_voting_power_schema_1.wise_rule_voting_power_decode(r);
        case "custom_rpc":
            return rule_custom_rpc_schema_1.wise_rule_custom_rpc_decode(r);
        case "votes_count":
            return rule_votes_count_schema_1.wise_rule_votes_count_decode(r);
        case "voters":
            return rule_voters_schema_1.wise_rule_voters_decode(r);
        case "first_post":
            return rule_first_post_schema_1.wise_rule_first_post_decode(r);
        case "payout":
            return rule_payout_schema_1.wise_rule_payout_decode(r);
        case "age_of_post":
            return rule_age_of_post_schema_1.wise_rule_age_of_post_decode(r);
        case "expiration_date":
            return rule_expiration_date_1.wise_rule_expiration_date_decode(r);
        default:
            // TODO: different_rule -> user should see a warning, and validation should fail: https://github.com/noisy-witness/steem-wise-core/issues/24
            throw new ValidationException_1.ValidationException("v2 unknown rule: '" + r.rule + "'");
    }
};
exports.wise_rule_encode = (r) => {
    switch (r.type()) {
        case Rule_1.Rule.Type.Weight:
            return rule_weight_schema_1.wise_rule_weight_encode(r);
        case Rule_1.Rule.Type.WeightForPeriod:
            return rule_weight_for_period_schema_1.wise_rule_weight_for_period_encode(r);
        case Rule_1.Rule.Type.Tags:
            return rule_tags_schema_1.wise_rule_tags_encode(r);
        case Rule_1.Rule.Type.Authors:
            return rule_authors_schema_1.wise_rule_authors_encode(r);
        case Rule_1.Rule.Type.VotingPower:
            return rule_voting_power_schema_1.wise_rule_voting_power_encode(r);
        case Rule_1.Rule.Type.CustomRPC:
            return rule_custom_rpc_schema_1.wise_rule_custom_rpc_encode(r);
        case Rule_1.Rule.Type.VotesCount:
            return rule_votes_count_schema_1.wise_rule_votes_count_encode(r);
        case Rule_1.Rule.Type.Voters:
            return rule_voters_schema_1.wise_rule_voters_encode(r);
        case Rule_1.Rule.Type.FirstPost:
            return rule_first_post_schema_1.wise_rule_first_post_encode(r);
        case Rule_1.Rule.Type.Payout:
            return rule_payout_schema_1.wise_rule_payout_encode(r);
        case Rule_1.Rule.Type.AgeOfPost:
            return rule_age_of_post_schema_1.wise_rule_age_of_post_encode(r);
        case Rule_1.Rule.Type.ExpirationDate:
            return rule_expiration_date_1.wise_rule_expiration_date_encode(r);
        default:
            // TODO: different_rule -> user should see a warning, and sending rules should fail: https://github.com/noisy-witness/steem-wise-core/issues/24
            throw new ValidationException_1.ValidationException("Rule type " + r.type() + " is not supported by V2 protocol handler.");
    }
};
//# sourceMappingURL=rules-schema.js.map