"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const VotesCountRule_1 = require("../../../../rules/VotesCountRule");
const ValidationException_1 = require("../../../../validation/ValidationException");
function wise_rule_votes_count_encode(r) {
    let mode;
    if (r.mode === VotesCountRule_1.VotesCountRule.Mode.EQUAL)
        mode = "equal";
    else if (r.mode === VotesCountRule_1.VotesCountRule.Mode.MORE_THAN)
        mode = "more_than";
    else if (r.mode === VotesCountRule_1.VotesCountRule.Mode.LESS_THAN)
        mode = "less_than";
    else
        throw new ValidationException_1.ValidationException("VotesCountRule: unknown mode " + r.mode);
    const out = {
        rule: "votes_count",
        mode: mode,
        value: r.value
    };
    return out;
}
exports.wise_rule_votes_count_encode = wise_rule_votes_count_encode;
function wise_rule_votes_count_decode(r) {
    let mode;
    if (r.mode === "equal")
        mode = VotesCountRule_1.VotesCountRule.Mode.EQUAL;
    else if (r.mode === "more_than")
        mode = VotesCountRule_1.VotesCountRule.Mode.MORE_THAN;
    else if (r.mode === "less_than")
        mode = VotesCountRule_1.VotesCountRule.Mode.LESS_THAN;
    else
        throw new ValidationException_1.ValidationException("v2:wise_rule_votes_count: unknown mode " + r.mode);
    return new VotesCountRule_1.VotesCountRule(mode, r.value);
}
exports.wise_rule_votes_count_decode = wise_rule_votes_count_decode;
//# sourceMappingURL=rule-votes-count-schema.js.map