"use strict";
/* tslint:disable class-name */
Object.defineProperty(exports, "__esModule", { value: true });
const TagsRule_1 = require("../../../../rules/TagsRule");
const ValidationException_1 = require("../../../../validation/ValidationException");
function wise_rule_tags_encode(r) {
    let mode;
    if (r.mode === TagsRule_1.TagsRule.Mode.ALLOW)
        mode = "allow";
    else if (r.mode === TagsRule_1.TagsRule.Mode.DENY)
        mode = "deny";
    else if (r.mode === TagsRule_1.TagsRule.Mode.ANY)
        mode = "any";
    else if (r.mode === TagsRule_1.TagsRule.Mode.REQUIRE)
        mode = "require";
    else
        throw new ValidationException_1.ValidationException("TagsRule: unknown mode " + r.mode);
    const out = {
        rule: "tags",
        mode: mode,
        tags: r.tags
    };
    return out;
}
exports.wise_rule_tags_encode = wise_rule_tags_encode;
function wise_rule_tags_decode(r) {
    let mode;
    if (r.mode === "allow")
        mode = TagsRule_1.TagsRule.Mode.ALLOW;
    else if (r.mode === "deny")
        mode = TagsRule_1.TagsRule.Mode.DENY;
    else if (r.mode === "require")
        mode = TagsRule_1.TagsRule.Mode.REQUIRE;
    else if (r.mode === "any")
        mode = TagsRule_1.TagsRule.Mode.ANY;
    else
        throw new ValidationException_1.ValidationException("v2:wise_rule_tags: unknown mode " + r.mode);
    return new TagsRule_1.TagsRule(mode, r.tags);
}
exports.wise_rule_tags_decode = wise_rule_tags_decode;
//# sourceMappingURL=rule-tags-schema.js.map