"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.permission_messages = void 0;
/**
 * Generated by the protoc-gen-ts.  DO NOT EDIT!
 * compiler version: 3.19.1
 * source: permissionmessages.proto
 * git: https://github.com/thesayyn/protoc-gen-ts */
const pb_1 = __importStar(require("google-protobuf"));
var permission_messages;
(function (permission_messages) {
    var _Permissions_one_of_decls, _ExplicitPermissions_one_of_decls, _PermissionsType_one_of_decls;
    let CacheRole;
    (function (CacheRole) {
        CacheRole[CacheRole["CachePermitNone"] = 0] = "CachePermitNone";
        CacheRole[CacheRole["CacheReadWrite"] = 1] = "CacheReadWrite";
        CacheRole[CacheRole["CacheReadOnly"] = 2] = "CacheReadOnly";
        CacheRole[CacheRole["CacheWriteOnly"] = 3] = "CacheWriteOnly";
    })(CacheRole = permission_messages.CacheRole || (permission_messages.CacheRole = {}));
    let TopicRole;
    (function (TopicRole) {
        TopicRole[TopicRole["TopicPermitNone"] = 0] = "TopicPermitNone";
        TopicRole[TopicRole["TopicReadWrite"] = 1] = "TopicReadWrite";
        TopicRole[TopicRole["TopicReadOnly"] = 2] = "TopicReadOnly";
        TopicRole[TopicRole["TopicWriteOnly"] = 3] = "TopicWriteOnly";
    })(TopicRole = permission_messages.TopicRole || (permission_messages.TopicRole = {}));
    let FunctionRole;
    (function (FunctionRole) {
        FunctionRole[FunctionRole["FunctionPermitNone"] = 0] = "FunctionPermitNone";
        FunctionRole[FunctionRole["FunctionInvoke"] = 1] = "FunctionInvoke";
    })(FunctionRole = permission_messages.FunctionRole || (permission_messages.FunctionRole = {}));
    let SuperUserPermissions;
    (function (SuperUserPermissions) {
        SuperUserPermissions[SuperUserPermissions["SuperUser"] = 0] = "SuperUser";
    })(SuperUserPermissions = permission_messages.SuperUserPermissions || (permission_messages.SuperUserPermissions = {}));
    class Permissions extends pb_1.Message {
        constructor(data) {
            super();
            _Permissions_one_of_decls.set(this, [[1, 2]]);
            pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], __classPrivateFieldGet(this, _Permissions_one_of_decls, "f"));
            if (!Array.isArray(data) && typeof data == "object") {
                if ("super_user" in data && data.super_user != undefined) {
                    this.super_user = data.super_user;
                }
                if ("explicit" in data && data.explicit != undefined) {
                    this.explicit = data.explicit;
                }
            }
        }
        get super_user() {
            return pb_1.Message.getFieldWithDefault(this, 1, SuperUserPermissions.SuperUser);
        }
        set super_user(value) {
            pb_1.Message.setOneofField(this, 1, __classPrivateFieldGet(this, _Permissions_one_of_decls, "f")[0], value);
        }
        get has_super_user() {
            return pb_1.Message.getField(this, 1) != null;
        }
        get explicit() {
            return pb_1.Message.getWrapperField(this, ExplicitPermissions, 2);
        }
        set explicit(value) {
            pb_1.Message.setOneofWrapperField(this, 2, __classPrivateFieldGet(this, _Permissions_one_of_decls, "f")[0], value);
        }
        get has_explicit() {
            return pb_1.Message.getField(this, 2) != null;
        }
        get kind() {
            const cases = {
                0: "none",
                1: "super_user",
                2: "explicit"
            };
            return cases[pb_1.Message.computeOneofCase(this, [1, 2])];
        }
        static fromObject(data) {
            const message = new Permissions({});
            if (data.super_user != null) {
                message.super_user = data.super_user;
            }
            if (data.explicit != null) {
                message.explicit = ExplicitPermissions.fromObject(data.explicit);
            }
            return message;
        }
        toObject() {
            const data = {};
            if (this.super_user != null) {
                data.super_user = this.super_user;
            }
            if (this.explicit != null) {
                data.explicit = this.explicit.toObject();
            }
            return data;
        }
        serialize(w) {
            const writer = w || new pb_1.BinaryWriter();
            if (this.has_super_user)
                writer.writeEnum(1, this.super_user);
            if (this.has_explicit)
                writer.writeMessage(2, this.explicit, () => this.explicit.serialize(writer));
            if (!w)
                return writer.getResultBuffer();
        }
        static deserialize(bytes) {
            const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new Permissions();
            while (reader.nextField()) {
                if (reader.isEndGroup())
                    break;
                switch (reader.getFieldNumber()) {
                    case 1:
                        message.super_user = reader.readEnum();
                        break;
                    case 2:
                        reader.readMessage(message.explicit, () => message.explicit = ExplicitPermissions.deserialize(reader));
                        break;
                    default: reader.skipField();
                }
            }
            return message;
        }
        serializeBinary() {
            return this.serialize();
        }
        static deserializeBinary(bytes) {
            return Permissions.deserialize(bytes);
        }
    }
    _Permissions_one_of_decls = new WeakMap();
    permission_messages.Permissions = Permissions;
    class ExplicitPermissions extends pb_1.Message {
        constructor(data) {
            super();
            _ExplicitPermissions_one_of_decls.set(this, []);
            pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [1], __classPrivateFieldGet(this, _ExplicitPermissions_one_of_decls, "f"));
            if (!Array.isArray(data) && typeof data == "object") {
                if ("permissions" in data && data.permissions != undefined) {
                    this.permissions = data.permissions;
                }
            }
        }
        get permissions() {
            return pb_1.Message.getRepeatedWrapperField(this, PermissionsType, 1);
        }
        set permissions(value) {
            pb_1.Message.setRepeatedWrapperField(this, 1, value);
        }
        static fromObject(data) {
            const message = new ExplicitPermissions({});
            if (data.permissions != null) {
                message.permissions = data.permissions.map(item => PermissionsType.fromObject(item));
            }
            return message;
        }
        toObject() {
            const data = {};
            if (this.permissions != null) {
                data.permissions = this.permissions.map((item) => item.toObject());
            }
            return data;
        }
        serialize(w) {
            const writer = w || new pb_1.BinaryWriter();
            if (this.permissions.length)
                writer.writeRepeatedMessage(1, this.permissions, (item) => item.serialize(writer));
            if (!w)
                return writer.getResultBuffer();
        }
        static deserialize(bytes) {
            const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new ExplicitPermissions();
            while (reader.nextField()) {
                if (reader.isEndGroup())
                    break;
                switch (reader.getFieldNumber()) {
                    case 1:
                        reader.readMessage(message.permissions, () => pb_1.Message.addToRepeatedWrapperField(message, 1, PermissionsType.deserialize(reader), PermissionsType));
                        break;
                    default: reader.skipField();
                }
            }
            return message;
        }
        serializeBinary() {
            return this.serialize();
        }
        static deserializeBinary(bytes) {
            return ExplicitPermissions.deserialize(bytes);
        }
    }
    _ExplicitPermissions_one_of_decls = new WeakMap();
    permission_messages.ExplicitPermissions = ExplicitPermissions;
    class PermissionsType extends pb_1.Message {
        constructor(data) {
            super();
            _PermissionsType_one_of_decls.set(this, [[1, 2, 3]]);
            pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], __classPrivateFieldGet(this, _PermissionsType_one_of_decls, "f"));
            if (!Array.isArray(data) && typeof data == "object") {
                if ("cache_permissions" in data && data.cache_permissions != undefined) {
                    this.cache_permissions = data.cache_permissions;
                }
                if ("topic_permissions" in data && data.topic_permissions != undefined) {
                    this.topic_permissions = data.topic_permissions;
                }
                if ("function_permissions" in data && data.function_permissions != undefined) {
                    this.function_permissions = data.function_permissions;
                }
            }
        }
        get cache_permissions() {
            return pb_1.Message.getWrapperField(this, PermissionsType.CachePermissions, 1);
        }
        set cache_permissions(value) {
            pb_1.Message.setOneofWrapperField(this, 1, __classPrivateFieldGet(this, _PermissionsType_one_of_decls, "f")[0], value);
        }
        get has_cache_permissions() {
            return pb_1.Message.getField(this, 1) != null;
        }
        get topic_permissions() {
            return pb_1.Message.getWrapperField(this, PermissionsType.TopicPermissions, 2);
        }
        set topic_permissions(value) {
            pb_1.Message.setOneofWrapperField(this, 2, __classPrivateFieldGet(this, _PermissionsType_one_of_decls, "f")[0], value);
        }
        get has_topic_permissions() {
            return pb_1.Message.getField(this, 2) != null;
        }
        get function_permissions() {
            return pb_1.Message.getWrapperField(this, PermissionsType.FunctionPermissions, 3);
        }
        set function_permissions(value) {
            pb_1.Message.setOneofWrapperField(this, 3, __classPrivateFieldGet(this, _PermissionsType_one_of_decls, "f")[0], value);
        }
        get has_function_permissions() {
            return pb_1.Message.getField(this, 3) != null;
        }
        get kind() {
            const cases = {
                0: "none",
                1: "cache_permissions",
                2: "topic_permissions",
                3: "function_permissions"
            };
            return cases[pb_1.Message.computeOneofCase(this, [1, 2, 3])];
        }
        static fromObject(data) {
            const message = new PermissionsType({});
            if (data.cache_permissions != null) {
                message.cache_permissions = PermissionsType.CachePermissions.fromObject(data.cache_permissions);
            }
            if (data.topic_permissions != null) {
                message.topic_permissions = PermissionsType.TopicPermissions.fromObject(data.topic_permissions);
            }
            if (data.function_permissions != null) {
                message.function_permissions = PermissionsType.FunctionPermissions.fromObject(data.function_permissions);
            }
            return message;
        }
        toObject() {
            const data = {};
            if (this.cache_permissions != null) {
                data.cache_permissions = this.cache_permissions.toObject();
            }
            if (this.topic_permissions != null) {
                data.topic_permissions = this.topic_permissions.toObject();
            }
            if (this.function_permissions != null) {
                data.function_permissions = this.function_permissions.toObject();
            }
            return data;
        }
        serialize(w) {
            const writer = w || new pb_1.BinaryWriter();
            if (this.has_cache_permissions)
                writer.writeMessage(1, this.cache_permissions, () => this.cache_permissions.serialize(writer));
            if (this.has_topic_permissions)
                writer.writeMessage(2, this.topic_permissions, () => this.topic_permissions.serialize(writer));
            if (this.has_function_permissions)
                writer.writeMessage(3, this.function_permissions, () => this.function_permissions.serialize(writer));
            if (!w)
                return writer.getResultBuffer();
        }
        static deserialize(bytes) {
            const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new PermissionsType();
            while (reader.nextField()) {
                if (reader.isEndGroup())
                    break;
                switch (reader.getFieldNumber()) {
                    case 1:
                        reader.readMessage(message.cache_permissions, () => message.cache_permissions = PermissionsType.CachePermissions.deserialize(reader));
                        break;
                    case 2:
                        reader.readMessage(message.topic_permissions, () => message.topic_permissions = PermissionsType.TopicPermissions.deserialize(reader));
                        break;
                    case 3:
                        reader.readMessage(message.function_permissions, () => message.function_permissions = PermissionsType.FunctionPermissions.deserialize(reader));
                        break;
                    default: reader.skipField();
                }
            }
            return message;
        }
        serializeBinary() {
            return this.serialize();
        }
        static deserializeBinary(bytes) {
            return PermissionsType.deserialize(bytes);
        }
    }
    _PermissionsType_one_of_decls = new WeakMap();
    permission_messages.PermissionsType = PermissionsType;
    (function (PermissionsType) {
        var _All_one_of_decls, _CacheSelector_one_of_decls, _CacheItemSelector_one_of_decls, _CachePermissions_one_of_decls, _TopicSelector_one_of_decls, _TopicPermissions_one_of_decls, _FunctionSelector_one_of_decls, _FunctionPermissions_one_of_decls;
        class All extends pb_1.Message {
            constructor(data) {
                super();
                _All_one_of_decls.set(this, []);
                pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], __classPrivateFieldGet(this, _All_one_of_decls, "f"));
                if (!Array.isArray(data) && typeof data == "object") { }
            }
            static fromObject(data) {
                const message = new All({});
                return message;
            }
            toObject() {
                const data = {};
                return data;
            }
            serialize(w) {
                const writer = w || new pb_1.BinaryWriter();
                if (!w)
                    return writer.getResultBuffer();
            }
            static deserialize(bytes) {
                const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new All();
                while (reader.nextField()) {
                    if (reader.isEndGroup())
                        break;
                    switch (reader.getFieldNumber()) {
                        default: reader.skipField();
                    }
                }
                return message;
            }
            serializeBinary() {
                return this.serialize();
            }
            static deserializeBinary(bytes) {
                return All.deserialize(bytes);
            }
        }
        _All_one_of_decls = new WeakMap();
        PermissionsType.All = All;
        class CacheSelector extends pb_1.Message {
            constructor(data) {
                super();
                _CacheSelector_one_of_decls.set(this, [[1]]);
                pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], __classPrivateFieldGet(this, _CacheSelector_one_of_decls, "f"));
                if (!Array.isArray(data) && typeof data == "object") {
                    if ("cache_name" in data && data.cache_name != undefined) {
                        this.cache_name = data.cache_name;
                    }
                }
            }
            get cache_name() {
                return pb_1.Message.getFieldWithDefault(this, 1, "");
            }
            set cache_name(value) {
                pb_1.Message.setOneofField(this, 1, __classPrivateFieldGet(this, _CacheSelector_one_of_decls, "f")[0], value);
            }
            get has_cache_name() {
                return pb_1.Message.getField(this, 1) != null;
            }
            get kind() {
                const cases = {
                    0: "none",
                    1: "cache_name"
                };
                return cases[pb_1.Message.computeOneofCase(this, [1])];
            }
            static fromObject(data) {
                const message = new CacheSelector({});
                if (data.cache_name != null) {
                    message.cache_name = data.cache_name;
                }
                return message;
            }
            toObject() {
                const data = {};
                if (this.cache_name != null) {
                    data.cache_name = this.cache_name;
                }
                return data;
            }
            serialize(w) {
                const writer = w || new pb_1.BinaryWriter();
                if (this.has_cache_name)
                    writer.writeString(1, this.cache_name);
                if (!w)
                    return writer.getResultBuffer();
            }
            static deserialize(bytes) {
                const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new CacheSelector();
                while (reader.nextField()) {
                    if (reader.isEndGroup())
                        break;
                    switch (reader.getFieldNumber()) {
                        case 1:
                            message.cache_name = reader.readString();
                            break;
                        default: reader.skipField();
                    }
                }
                return message;
            }
            serializeBinary() {
                return this.serialize();
            }
            static deserializeBinary(bytes) {
                return CacheSelector.deserialize(bytes);
            }
        }
        _CacheSelector_one_of_decls = new WeakMap();
        PermissionsType.CacheSelector = CacheSelector;
        class CacheItemSelector extends pb_1.Message {
            constructor(data) {
                super();
                _CacheItemSelector_one_of_decls.set(this, [[1, 2]]);
                pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], __classPrivateFieldGet(this, _CacheItemSelector_one_of_decls, "f"));
                if (!Array.isArray(data) && typeof data == "object") {
                    if ("key" in data && data.key != undefined) {
                        this.key = data.key;
                    }
                    if ("key_prefix" in data && data.key_prefix != undefined) {
                        this.key_prefix = data.key_prefix;
                    }
                }
            }
            get key() {
                return pb_1.Message.getFieldWithDefault(this, 1, new Uint8Array(0));
            }
            set key(value) {
                pb_1.Message.setOneofField(this, 1, __classPrivateFieldGet(this, _CacheItemSelector_one_of_decls, "f")[0], value);
            }
            get has_key() {
                return pb_1.Message.getField(this, 1) != null;
            }
            get key_prefix() {
                return pb_1.Message.getFieldWithDefault(this, 2, new Uint8Array(0));
            }
            set key_prefix(value) {
                pb_1.Message.setOneofField(this, 2, __classPrivateFieldGet(this, _CacheItemSelector_one_of_decls, "f")[0], value);
            }
            get has_key_prefix() {
                return pb_1.Message.getField(this, 2) != null;
            }
            get kind() {
                const cases = {
                    0: "none",
                    1: "key",
                    2: "key_prefix"
                };
                return cases[pb_1.Message.computeOneofCase(this, [1, 2])];
            }
            static fromObject(data) {
                const message = new CacheItemSelector({});
                if (data.key != null) {
                    message.key = data.key;
                }
                if (data.key_prefix != null) {
                    message.key_prefix = data.key_prefix;
                }
                return message;
            }
            toObject() {
                const data = {};
                if (this.key != null) {
                    data.key = this.key;
                }
                if (this.key_prefix != null) {
                    data.key_prefix = this.key_prefix;
                }
                return data;
            }
            serialize(w) {
                const writer = w || new pb_1.BinaryWriter();
                if (this.has_key)
                    writer.writeBytes(1, this.key);
                if (this.has_key_prefix)
                    writer.writeBytes(2, this.key_prefix);
                if (!w)
                    return writer.getResultBuffer();
            }
            static deserialize(bytes) {
                const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new CacheItemSelector();
                while (reader.nextField()) {
                    if (reader.isEndGroup())
                        break;
                    switch (reader.getFieldNumber()) {
                        case 1:
                            message.key = reader.readBytes();
                            break;
                        case 2:
                            message.key_prefix = reader.readBytes();
                            break;
                        default: reader.skipField();
                    }
                }
                return message;
            }
            serializeBinary() {
                return this.serialize();
            }
            static deserializeBinary(bytes) {
                return CacheItemSelector.deserialize(bytes);
            }
        }
        _CacheItemSelector_one_of_decls = new WeakMap();
        PermissionsType.CacheItemSelector = CacheItemSelector;
        class CachePermissions extends pb_1.Message {
            constructor(data) {
                super();
                _CachePermissions_one_of_decls.set(this, [[2, 3], [4, 5]]);
                pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], __classPrivateFieldGet(this, _CachePermissions_one_of_decls, "f"));
                if (!Array.isArray(data) && typeof data == "object") {
                    if ("role" in data && data.role != undefined) {
                        this.role = data.role;
                    }
                    if ("all_caches" in data && data.all_caches != undefined) {
                        this.all_caches = data.all_caches;
                    }
                    if ("cache_selector" in data && data.cache_selector != undefined) {
                        this.cache_selector = data.cache_selector;
                    }
                    if ("all_items" in data && data.all_items != undefined) {
                        this.all_items = data.all_items;
                    }
                    if ("item_selector" in data && data.item_selector != undefined) {
                        this.item_selector = data.item_selector;
                    }
                }
            }
            get role() {
                return pb_1.Message.getFieldWithDefault(this, 1, CacheRole.CachePermitNone);
            }
            set role(value) {
                pb_1.Message.setField(this, 1, value);
            }
            get all_caches() {
                return pb_1.Message.getWrapperField(this, PermissionsType.All, 2);
            }
            set all_caches(value) {
                pb_1.Message.setOneofWrapperField(this, 2, __classPrivateFieldGet(this, _CachePermissions_one_of_decls, "f")[0], value);
            }
            get has_all_caches() {
                return pb_1.Message.getField(this, 2) != null;
            }
            get cache_selector() {
                return pb_1.Message.getWrapperField(this, PermissionsType.CacheSelector, 3);
            }
            set cache_selector(value) {
                pb_1.Message.setOneofWrapperField(this, 3, __classPrivateFieldGet(this, _CachePermissions_one_of_decls, "f")[0], value);
            }
            get has_cache_selector() {
                return pb_1.Message.getField(this, 3) != null;
            }
            get all_items() {
                return pb_1.Message.getWrapperField(this, PermissionsType.All, 4);
            }
            set all_items(value) {
                pb_1.Message.setOneofWrapperField(this, 4, __classPrivateFieldGet(this, _CachePermissions_one_of_decls, "f")[1], value);
            }
            get has_all_items() {
                return pb_1.Message.getField(this, 4) != null;
            }
            get item_selector() {
                return pb_1.Message.getWrapperField(this, PermissionsType.CacheItemSelector, 5);
            }
            set item_selector(value) {
                pb_1.Message.setOneofWrapperField(this, 5, __classPrivateFieldGet(this, _CachePermissions_one_of_decls, "f")[1], value);
            }
            get has_item_selector() {
                return pb_1.Message.getField(this, 5) != null;
            }
            get cache() {
                const cases = {
                    0: "none",
                    2: "all_caches",
                    3: "cache_selector"
                };
                return cases[pb_1.Message.computeOneofCase(this, [2, 3])];
            }
            get cache_item() {
                const cases = {
                    0: "none",
                    4: "all_items",
                    5: "item_selector"
                };
                return cases[pb_1.Message.computeOneofCase(this, [4, 5])];
            }
            static fromObject(data) {
                const message = new CachePermissions({});
                if (data.role != null) {
                    message.role = data.role;
                }
                if (data.all_caches != null) {
                    message.all_caches = PermissionsType.All.fromObject(data.all_caches);
                }
                if (data.cache_selector != null) {
                    message.cache_selector = PermissionsType.CacheSelector.fromObject(data.cache_selector);
                }
                if (data.all_items != null) {
                    message.all_items = PermissionsType.All.fromObject(data.all_items);
                }
                if (data.item_selector != null) {
                    message.item_selector = PermissionsType.CacheItemSelector.fromObject(data.item_selector);
                }
                return message;
            }
            toObject() {
                const data = {};
                if (this.role != null) {
                    data.role = this.role;
                }
                if (this.all_caches != null) {
                    data.all_caches = this.all_caches.toObject();
                }
                if (this.cache_selector != null) {
                    data.cache_selector = this.cache_selector.toObject();
                }
                if (this.all_items != null) {
                    data.all_items = this.all_items.toObject();
                }
                if (this.item_selector != null) {
                    data.item_selector = this.item_selector.toObject();
                }
                return data;
            }
            serialize(w) {
                const writer = w || new pb_1.BinaryWriter();
                if (this.role != CacheRole.CachePermitNone)
                    writer.writeEnum(1, this.role);
                if (this.has_all_caches)
                    writer.writeMessage(2, this.all_caches, () => this.all_caches.serialize(writer));
                if (this.has_cache_selector)
                    writer.writeMessage(3, this.cache_selector, () => this.cache_selector.serialize(writer));
                if (this.has_all_items)
                    writer.writeMessage(4, this.all_items, () => this.all_items.serialize(writer));
                if (this.has_item_selector)
                    writer.writeMessage(5, this.item_selector, () => this.item_selector.serialize(writer));
                if (!w)
                    return writer.getResultBuffer();
            }
            static deserialize(bytes) {
                const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new CachePermissions();
                while (reader.nextField()) {
                    if (reader.isEndGroup())
                        break;
                    switch (reader.getFieldNumber()) {
                        case 1:
                            message.role = reader.readEnum();
                            break;
                        case 2:
                            reader.readMessage(message.all_caches, () => message.all_caches = PermissionsType.All.deserialize(reader));
                            break;
                        case 3:
                            reader.readMessage(message.cache_selector, () => message.cache_selector = PermissionsType.CacheSelector.deserialize(reader));
                            break;
                        case 4:
                            reader.readMessage(message.all_items, () => message.all_items = PermissionsType.All.deserialize(reader));
                            break;
                        case 5:
                            reader.readMessage(message.item_selector, () => message.item_selector = PermissionsType.CacheItemSelector.deserialize(reader));
                            break;
                        default: reader.skipField();
                    }
                }
                return message;
            }
            serializeBinary() {
                return this.serialize();
            }
            static deserializeBinary(bytes) {
                return CachePermissions.deserialize(bytes);
            }
        }
        _CachePermissions_one_of_decls = new WeakMap();
        PermissionsType.CachePermissions = CachePermissions;
        class TopicSelector extends pb_1.Message {
            constructor(data) {
                super();
                _TopicSelector_one_of_decls.set(this, [[1, 2]]);
                pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], __classPrivateFieldGet(this, _TopicSelector_one_of_decls, "f"));
                if (!Array.isArray(data) && typeof data == "object") {
                    if ("topic_name" in data && data.topic_name != undefined) {
                        this.topic_name = data.topic_name;
                    }
                    if ("topic_name_prefix" in data && data.topic_name_prefix != undefined) {
                        this.topic_name_prefix = data.topic_name_prefix;
                    }
                }
            }
            get topic_name() {
                return pb_1.Message.getFieldWithDefault(this, 1, "");
            }
            set topic_name(value) {
                pb_1.Message.setOneofField(this, 1, __classPrivateFieldGet(this, _TopicSelector_one_of_decls, "f")[0], value);
            }
            get has_topic_name() {
                return pb_1.Message.getField(this, 1) != null;
            }
            get topic_name_prefix() {
                return pb_1.Message.getFieldWithDefault(this, 2, "");
            }
            set topic_name_prefix(value) {
                pb_1.Message.setOneofField(this, 2, __classPrivateFieldGet(this, _TopicSelector_one_of_decls, "f")[0], value);
            }
            get has_topic_name_prefix() {
                return pb_1.Message.getField(this, 2) != null;
            }
            get kind() {
                const cases = {
                    0: "none",
                    1: "topic_name",
                    2: "topic_name_prefix"
                };
                return cases[pb_1.Message.computeOneofCase(this, [1, 2])];
            }
            static fromObject(data) {
                const message = new TopicSelector({});
                if (data.topic_name != null) {
                    message.topic_name = data.topic_name;
                }
                if (data.topic_name_prefix != null) {
                    message.topic_name_prefix = data.topic_name_prefix;
                }
                return message;
            }
            toObject() {
                const data = {};
                if (this.topic_name != null) {
                    data.topic_name = this.topic_name;
                }
                if (this.topic_name_prefix != null) {
                    data.topic_name_prefix = this.topic_name_prefix;
                }
                return data;
            }
            serialize(w) {
                const writer = w || new pb_1.BinaryWriter();
                if (this.has_topic_name)
                    writer.writeString(1, this.topic_name);
                if (this.has_topic_name_prefix)
                    writer.writeString(2, this.topic_name_prefix);
                if (!w)
                    return writer.getResultBuffer();
            }
            static deserialize(bytes) {
                const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new TopicSelector();
                while (reader.nextField()) {
                    if (reader.isEndGroup())
                        break;
                    switch (reader.getFieldNumber()) {
                        case 1:
                            message.topic_name = reader.readString();
                            break;
                        case 2:
                            message.topic_name_prefix = reader.readString();
                            break;
                        default: reader.skipField();
                    }
                }
                return message;
            }
            serializeBinary() {
                return this.serialize();
            }
            static deserializeBinary(bytes) {
                return TopicSelector.deserialize(bytes);
            }
        }
        _TopicSelector_one_of_decls = new WeakMap();
        PermissionsType.TopicSelector = TopicSelector;
        class TopicPermissions extends pb_1.Message {
            constructor(data) {
                super();
                _TopicPermissions_one_of_decls.set(this, [[2, 3], [4, 5]]);
                pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], __classPrivateFieldGet(this, _TopicPermissions_one_of_decls, "f"));
                if (!Array.isArray(data) && typeof data == "object") {
                    if ("role" in data && data.role != undefined) {
                        this.role = data.role;
                    }
                    if ("all_caches" in data && data.all_caches != undefined) {
                        this.all_caches = data.all_caches;
                    }
                    if ("cache_selector" in data && data.cache_selector != undefined) {
                        this.cache_selector = data.cache_selector;
                    }
                    if ("all_topics" in data && data.all_topics != undefined) {
                        this.all_topics = data.all_topics;
                    }
                    if ("topic_selector" in data && data.topic_selector != undefined) {
                        this.topic_selector = data.topic_selector;
                    }
                }
            }
            get role() {
                return pb_1.Message.getFieldWithDefault(this, 1, TopicRole.TopicPermitNone);
            }
            set role(value) {
                pb_1.Message.setField(this, 1, value);
            }
            get all_caches() {
                return pb_1.Message.getWrapperField(this, PermissionsType.All, 2);
            }
            set all_caches(value) {
                pb_1.Message.setOneofWrapperField(this, 2, __classPrivateFieldGet(this, _TopicPermissions_one_of_decls, "f")[0], value);
            }
            get has_all_caches() {
                return pb_1.Message.getField(this, 2) != null;
            }
            get cache_selector() {
                return pb_1.Message.getWrapperField(this, PermissionsType.CacheSelector, 3);
            }
            set cache_selector(value) {
                pb_1.Message.setOneofWrapperField(this, 3, __classPrivateFieldGet(this, _TopicPermissions_one_of_decls, "f")[0], value);
            }
            get has_cache_selector() {
                return pb_1.Message.getField(this, 3) != null;
            }
            get all_topics() {
                return pb_1.Message.getWrapperField(this, PermissionsType.All, 4);
            }
            set all_topics(value) {
                pb_1.Message.setOneofWrapperField(this, 4, __classPrivateFieldGet(this, _TopicPermissions_one_of_decls, "f")[1], value);
            }
            get has_all_topics() {
                return pb_1.Message.getField(this, 4) != null;
            }
            get topic_selector() {
                return pb_1.Message.getWrapperField(this, PermissionsType.TopicSelector, 5);
            }
            set topic_selector(value) {
                pb_1.Message.setOneofWrapperField(this, 5, __classPrivateFieldGet(this, _TopicPermissions_one_of_decls, "f")[1], value);
            }
            get has_topic_selector() {
                return pb_1.Message.getField(this, 5) != null;
            }
            get cache() {
                const cases = {
                    0: "none",
                    2: "all_caches",
                    3: "cache_selector"
                };
                return cases[pb_1.Message.computeOneofCase(this, [2, 3])];
            }
            get topic() {
                const cases = {
                    0: "none",
                    4: "all_topics",
                    5: "topic_selector"
                };
                return cases[pb_1.Message.computeOneofCase(this, [4, 5])];
            }
            static fromObject(data) {
                const message = new TopicPermissions({});
                if (data.role != null) {
                    message.role = data.role;
                }
                if (data.all_caches != null) {
                    message.all_caches = PermissionsType.All.fromObject(data.all_caches);
                }
                if (data.cache_selector != null) {
                    message.cache_selector = PermissionsType.CacheSelector.fromObject(data.cache_selector);
                }
                if (data.all_topics != null) {
                    message.all_topics = PermissionsType.All.fromObject(data.all_topics);
                }
                if (data.topic_selector != null) {
                    message.topic_selector = PermissionsType.TopicSelector.fromObject(data.topic_selector);
                }
                return message;
            }
            toObject() {
                const data = {};
                if (this.role != null) {
                    data.role = this.role;
                }
                if (this.all_caches != null) {
                    data.all_caches = this.all_caches.toObject();
                }
                if (this.cache_selector != null) {
                    data.cache_selector = this.cache_selector.toObject();
                }
                if (this.all_topics != null) {
                    data.all_topics = this.all_topics.toObject();
                }
                if (this.topic_selector != null) {
                    data.topic_selector = this.topic_selector.toObject();
                }
                return data;
            }
            serialize(w) {
                const writer = w || new pb_1.BinaryWriter();
                if (this.role != TopicRole.TopicPermitNone)
                    writer.writeEnum(1, this.role);
                if (this.has_all_caches)
                    writer.writeMessage(2, this.all_caches, () => this.all_caches.serialize(writer));
                if (this.has_cache_selector)
                    writer.writeMessage(3, this.cache_selector, () => this.cache_selector.serialize(writer));
                if (this.has_all_topics)
                    writer.writeMessage(4, this.all_topics, () => this.all_topics.serialize(writer));
                if (this.has_topic_selector)
                    writer.writeMessage(5, this.topic_selector, () => this.topic_selector.serialize(writer));
                if (!w)
                    return writer.getResultBuffer();
            }
            static deserialize(bytes) {
                const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new TopicPermissions();
                while (reader.nextField()) {
                    if (reader.isEndGroup())
                        break;
                    switch (reader.getFieldNumber()) {
                        case 1:
                            message.role = reader.readEnum();
                            break;
                        case 2:
                            reader.readMessage(message.all_caches, () => message.all_caches = PermissionsType.All.deserialize(reader));
                            break;
                        case 3:
                            reader.readMessage(message.cache_selector, () => message.cache_selector = PermissionsType.CacheSelector.deserialize(reader));
                            break;
                        case 4:
                            reader.readMessage(message.all_topics, () => message.all_topics = PermissionsType.All.deserialize(reader));
                            break;
                        case 5:
                            reader.readMessage(message.topic_selector, () => message.topic_selector = PermissionsType.TopicSelector.deserialize(reader));
                            break;
                        default: reader.skipField();
                    }
                }
                return message;
            }
            serializeBinary() {
                return this.serialize();
            }
            static deserializeBinary(bytes) {
                return TopicPermissions.deserialize(bytes);
            }
        }
        _TopicPermissions_one_of_decls = new WeakMap();
        PermissionsType.TopicPermissions = TopicPermissions;
        class FunctionSelector extends pb_1.Message {
            constructor(data) {
                super();
                _FunctionSelector_one_of_decls.set(this, [[1, 2]]);
                pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], __classPrivateFieldGet(this, _FunctionSelector_one_of_decls, "f"));
                if (!Array.isArray(data) && typeof data == "object") {
                    if ("function_name" in data && data.function_name != undefined) {
                        this.function_name = data.function_name;
                    }
                    if ("function_name_prefix" in data && data.function_name_prefix != undefined) {
                        this.function_name_prefix = data.function_name_prefix;
                    }
                }
            }
            get function_name() {
                return pb_1.Message.getFieldWithDefault(this, 1, "");
            }
            set function_name(value) {
                pb_1.Message.setOneofField(this, 1, __classPrivateFieldGet(this, _FunctionSelector_one_of_decls, "f")[0], value);
            }
            get has_function_name() {
                return pb_1.Message.getField(this, 1) != null;
            }
            get function_name_prefix() {
                return pb_1.Message.getFieldWithDefault(this, 2, "");
            }
            set function_name_prefix(value) {
                pb_1.Message.setOneofField(this, 2, __classPrivateFieldGet(this, _FunctionSelector_one_of_decls, "f")[0], value);
            }
            get has_function_name_prefix() {
                return pb_1.Message.getField(this, 2) != null;
            }
            get kind() {
                const cases = {
                    0: "none",
                    1: "function_name",
                    2: "function_name_prefix"
                };
                return cases[pb_1.Message.computeOneofCase(this, [1, 2])];
            }
            static fromObject(data) {
                const message = new FunctionSelector({});
                if (data.function_name != null) {
                    message.function_name = data.function_name;
                }
                if (data.function_name_prefix != null) {
                    message.function_name_prefix = data.function_name_prefix;
                }
                return message;
            }
            toObject() {
                const data = {};
                if (this.function_name != null) {
                    data.function_name = this.function_name;
                }
                if (this.function_name_prefix != null) {
                    data.function_name_prefix = this.function_name_prefix;
                }
                return data;
            }
            serialize(w) {
                const writer = w || new pb_1.BinaryWriter();
                if (this.has_function_name)
                    writer.writeString(1, this.function_name);
                if (this.has_function_name_prefix)
                    writer.writeString(2, this.function_name_prefix);
                if (!w)
                    return writer.getResultBuffer();
            }
            static deserialize(bytes) {
                const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new FunctionSelector();
                while (reader.nextField()) {
                    if (reader.isEndGroup())
                        break;
                    switch (reader.getFieldNumber()) {
                        case 1:
                            message.function_name = reader.readString();
                            break;
                        case 2:
                            message.function_name_prefix = reader.readString();
                            break;
                        default: reader.skipField();
                    }
                }
                return message;
            }
            serializeBinary() {
                return this.serialize();
            }
            static deserializeBinary(bytes) {
                return FunctionSelector.deserialize(bytes);
            }
        }
        _FunctionSelector_one_of_decls = new WeakMap();
        PermissionsType.FunctionSelector = FunctionSelector;
        class FunctionPermissions extends pb_1.Message {
            constructor(data) {
                super();
                _FunctionPermissions_one_of_decls.set(this, [[2, 3], [4, 5]]);
                pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], __classPrivateFieldGet(this, _FunctionPermissions_one_of_decls, "f"));
                if (!Array.isArray(data) && typeof data == "object") {
                    if ("role" in data && data.role != undefined) {
                        this.role = data.role;
                    }
                    if ("all_caches" in data && data.all_caches != undefined) {
                        this.all_caches = data.all_caches;
                    }
                    if ("cache_selector" in data && data.cache_selector != undefined) {
                        this.cache_selector = data.cache_selector;
                    }
                    if ("all_functions" in data && data.all_functions != undefined) {
                        this.all_functions = data.all_functions;
                    }
                    if ("function_selector" in data && data.function_selector != undefined) {
                        this.function_selector = data.function_selector;
                    }
                }
            }
            get role() {
                return pb_1.Message.getFieldWithDefault(this, 1, FunctionRole.FunctionPermitNone);
            }
            set role(value) {
                pb_1.Message.setField(this, 1, value);
            }
            get all_caches() {
                return pb_1.Message.getWrapperField(this, PermissionsType.All, 2);
            }
            set all_caches(value) {
                pb_1.Message.setOneofWrapperField(this, 2, __classPrivateFieldGet(this, _FunctionPermissions_one_of_decls, "f")[0], value);
            }
            get has_all_caches() {
                return pb_1.Message.getField(this, 2) != null;
            }
            get cache_selector() {
                return pb_1.Message.getWrapperField(this, PermissionsType.CacheSelector, 3);
            }
            set cache_selector(value) {
                pb_1.Message.setOneofWrapperField(this, 3, __classPrivateFieldGet(this, _FunctionPermissions_one_of_decls, "f")[0], value);
            }
            get has_cache_selector() {
                return pb_1.Message.getField(this, 3) != null;
            }
            get all_functions() {
                return pb_1.Message.getWrapperField(this, PermissionsType.All, 4);
            }
            set all_functions(value) {
                pb_1.Message.setOneofWrapperField(this, 4, __classPrivateFieldGet(this, _FunctionPermissions_one_of_decls, "f")[1], value);
            }
            get has_all_functions() {
                return pb_1.Message.getField(this, 4) != null;
            }
            get function_selector() {
                return pb_1.Message.getWrapperField(this, PermissionsType.FunctionSelector, 5);
            }
            set function_selector(value) {
                pb_1.Message.setOneofWrapperField(this, 5, __classPrivateFieldGet(this, _FunctionPermissions_one_of_decls, "f")[1], value);
            }
            get has_function_selector() {
                return pb_1.Message.getField(this, 5) != null;
            }
            get cache() {
                const cases = {
                    0: "none",
                    2: "all_caches",
                    3: "cache_selector"
                };
                return cases[pb_1.Message.computeOneofCase(this, [2, 3])];
            }
            get function() {
                const cases = {
                    0: "none",
                    4: "all_functions",
                    5: "function_selector"
                };
                return cases[pb_1.Message.computeOneofCase(this, [4, 5])];
            }
            static fromObject(data) {
                const message = new FunctionPermissions({});
                if (data.role != null) {
                    message.role = data.role;
                }
                if (data.all_caches != null) {
                    message.all_caches = PermissionsType.All.fromObject(data.all_caches);
                }
                if (data.cache_selector != null) {
                    message.cache_selector = PermissionsType.CacheSelector.fromObject(data.cache_selector);
                }
                if (data.all_functions != null) {
                    message.all_functions = PermissionsType.All.fromObject(data.all_functions);
                }
                if (data.function_selector != null) {
                    message.function_selector = PermissionsType.FunctionSelector.fromObject(data.function_selector);
                }
                return message;
            }
            toObject() {
                const data = {};
                if (this.role != null) {
                    data.role = this.role;
                }
                if (this.all_caches != null) {
                    data.all_caches = this.all_caches.toObject();
                }
                if (this.cache_selector != null) {
                    data.cache_selector = this.cache_selector.toObject();
                }
                if (this.all_functions != null) {
                    data.all_functions = this.all_functions.toObject();
                }
                if (this.function_selector != null) {
                    data.function_selector = this.function_selector.toObject();
                }
                return data;
            }
            serialize(w) {
                const writer = w || new pb_1.BinaryWriter();
                if (this.role != FunctionRole.FunctionPermitNone)
                    writer.writeEnum(1, this.role);
                if (this.has_all_caches)
                    writer.writeMessage(2, this.all_caches, () => this.all_caches.serialize(writer));
                if (this.has_cache_selector)
                    writer.writeMessage(3, this.cache_selector, () => this.cache_selector.serialize(writer));
                if (this.has_all_functions)
                    writer.writeMessage(4, this.all_functions, () => this.all_functions.serialize(writer));
                if (this.has_function_selector)
                    writer.writeMessage(5, this.function_selector, () => this.function_selector.serialize(writer));
                if (!w)
                    return writer.getResultBuffer();
            }
            static deserialize(bytes) {
                const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new FunctionPermissions();
                while (reader.nextField()) {
                    if (reader.isEndGroup())
                        break;
                    switch (reader.getFieldNumber()) {
                        case 1:
                            message.role = reader.readEnum();
                            break;
                        case 2:
                            reader.readMessage(message.all_caches, () => message.all_caches = PermissionsType.All.deserialize(reader));
                            break;
                        case 3:
                            reader.readMessage(message.cache_selector, () => message.cache_selector = PermissionsType.CacheSelector.deserialize(reader));
                            break;
                        case 4:
                            reader.readMessage(message.all_functions, () => message.all_functions = PermissionsType.All.deserialize(reader));
                            break;
                        case 5:
                            reader.readMessage(message.function_selector, () => message.function_selector = PermissionsType.FunctionSelector.deserialize(reader));
                            break;
                        default: reader.skipField();
                    }
                }
                return message;
            }
            serializeBinary() {
                return this.serialize();
            }
            static deserializeBinary(bytes) {
                return FunctionPermissions.deserialize(bytes);
            }
        }
        _FunctionPermissions_one_of_decls = new WeakMap();
        PermissionsType.FunctionPermissions = FunctionPermissions;
    })(PermissionsType = permission_messages.PermissionsType || (permission_messages.PermissionsType = {}));
})(permission_messages = exports.permission_messages || (exports.permission_messages = {}));
