"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.token = void 0;
/**
 * Generated by the protoc-gen-ts.  DO NOT EDIT!
 * compiler version: 3.19.1
 * source: token.proto
 * git: https://github.com/thesayyn/protoc-gen-ts */
const dependency_1 = __importStar(require("./permissionmessages"));
const pb_1 = __importStar(require("google-protobuf"));
const grpc_1 = __importStar(require("@grpc/grpc-js"));
var token;
(function (token) {
    var __GenerateDisposableTokenRequest_one_of_decls, __GenerateDisposableTokenResponse_one_of_decls;
    class _GenerateDisposableTokenRequest extends pb_1.Message {
        constructor(data) {
            super();
            __GenerateDisposableTokenRequest_one_of_decls.set(this, []);
            pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], __classPrivateFieldGet(this, __GenerateDisposableTokenRequest_one_of_decls, "f"));
            if (!Array.isArray(data) && typeof data == "object") {
                if ("expires" in data && data.expires != undefined) {
                    this.expires = data.expires;
                }
                if ("auth_token" in data && data.auth_token != undefined) {
                    this.auth_token = data.auth_token;
                }
                if ("permissions" in data && data.permissions != undefined) {
                    this.permissions = data.permissions;
                }
                if ("token_id" in data && data.token_id != undefined) {
                    this.token_id = data.token_id;
                }
            }
        }
        get expires() {
            return pb_1.Message.getWrapperField(this, _GenerateDisposableTokenRequest.Expires, 1);
        }
        set expires(value) {
            pb_1.Message.setWrapperField(this, 1, value);
        }
        get has_expires() {
            return pb_1.Message.getField(this, 1) != null;
        }
        get auth_token() {
            return pb_1.Message.getFieldWithDefault(this, 2, "");
        }
        set auth_token(value) {
            pb_1.Message.setField(this, 2, value);
        }
        get permissions() {
            return pb_1.Message.getWrapperField(this, dependency_1.permission_messages.Permissions, 3);
        }
        set permissions(value) {
            pb_1.Message.setWrapperField(this, 3, value);
        }
        get has_permissions() {
            return pb_1.Message.getField(this, 3) != null;
        }
        get token_id() {
            return pb_1.Message.getFieldWithDefault(this, 4, "");
        }
        set token_id(value) {
            pb_1.Message.setField(this, 4, value);
        }
        static fromObject(data) {
            const message = new _GenerateDisposableTokenRequest({});
            if (data.expires != null) {
                message.expires = _GenerateDisposableTokenRequest.Expires.fromObject(data.expires);
            }
            if (data.auth_token != null) {
                message.auth_token = data.auth_token;
            }
            if (data.permissions != null) {
                message.permissions = dependency_1.permission_messages.Permissions.fromObject(data.permissions);
            }
            if (data.token_id != null) {
                message.token_id = data.token_id;
            }
            return message;
        }
        toObject() {
            const data = {};
            if (this.expires != null) {
                data.expires = this.expires.toObject();
            }
            if (this.auth_token != null) {
                data.auth_token = this.auth_token;
            }
            if (this.permissions != null) {
                data.permissions = this.permissions.toObject();
            }
            if (this.token_id != null) {
                data.token_id = this.token_id;
            }
            return data;
        }
        serialize(w) {
            const writer = w || new pb_1.BinaryWriter();
            if (this.has_expires)
                writer.writeMessage(1, this.expires, () => this.expires.serialize(writer));
            if (this.auth_token.length)
                writer.writeString(2, this.auth_token);
            if (this.has_permissions)
                writer.writeMessage(3, this.permissions, () => this.permissions.serialize(writer));
            if (this.token_id.length)
                writer.writeString(4, this.token_id);
            if (!w)
                return writer.getResultBuffer();
        }
        static deserialize(bytes) {
            const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new _GenerateDisposableTokenRequest();
            while (reader.nextField()) {
                if (reader.isEndGroup())
                    break;
                switch (reader.getFieldNumber()) {
                    case 1:
                        reader.readMessage(message.expires, () => message.expires = _GenerateDisposableTokenRequest.Expires.deserialize(reader));
                        break;
                    case 2:
                        message.auth_token = reader.readString();
                        break;
                    case 3:
                        reader.readMessage(message.permissions, () => message.permissions = dependency_1.permission_messages.Permissions.deserialize(reader));
                        break;
                    case 4:
                        message.token_id = reader.readString();
                        break;
                    default: reader.skipField();
                }
            }
            return message;
        }
        serializeBinary() {
            return this.serialize();
        }
        static deserializeBinary(bytes) {
            return _GenerateDisposableTokenRequest.deserialize(bytes);
        }
    }
    __GenerateDisposableTokenRequest_one_of_decls = new WeakMap();
    token._GenerateDisposableTokenRequest = _GenerateDisposableTokenRequest;
    (function (_GenerateDisposableTokenRequest) {
        var _Expires_one_of_decls;
        class Expires extends pb_1.Message {
            constructor(data) {
                super();
                _Expires_one_of_decls.set(this, []);
                pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], __classPrivateFieldGet(this, _Expires_one_of_decls, "f"));
                if (!Array.isArray(data) && typeof data == "object") {
                    if ("valid_for_seconds" in data && data.valid_for_seconds != undefined) {
                        this.valid_for_seconds = data.valid_for_seconds;
                    }
                }
            }
            get valid_for_seconds() {
                return pb_1.Message.getFieldWithDefault(this, 1, 0);
            }
            set valid_for_seconds(value) {
                pb_1.Message.setField(this, 1, value);
            }
            static fromObject(data) {
                const message = new Expires({});
                if (data.valid_for_seconds != null) {
                    message.valid_for_seconds = data.valid_for_seconds;
                }
                return message;
            }
            toObject() {
                const data = {};
                if (this.valid_for_seconds != null) {
                    data.valid_for_seconds = this.valid_for_seconds;
                }
                return data;
            }
            serialize(w) {
                const writer = w || new pb_1.BinaryWriter();
                if (this.valid_for_seconds != 0)
                    writer.writeUint32(1, this.valid_for_seconds);
                if (!w)
                    return writer.getResultBuffer();
            }
            static deserialize(bytes) {
                const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new Expires();
                while (reader.nextField()) {
                    if (reader.isEndGroup())
                        break;
                    switch (reader.getFieldNumber()) {
                        case 1:
                            message.valid_for_seconds = reader.readUint32();
                            break;
                        default: reader.skipField();
                    }
                }
                return message;
            }
            serializeBinary() {
                return this.serialize();
            }
            static deserializeBinary(bytes) {
                return Expires.deserialize(bytes);
            }
        }
        _Expires_one_of_decls = new WeakMap();
        _GenerateDisposableTokenRequest.Expires = Expires;
    })(_GenerateDisposableTokenRequest = token._GenerateDisposableTokenRequest || (token._GenerateDisposableTokenRequest = {}));
    class _GenerateDisposableTokenResponse extends pb_1.Message {
        constructor(data) {
            super();
            __GenerateDisposableTokenResponse_one_of_decls.set(this, []);
            pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], __classPrivateFieldGet(this, __GenerateDisposableTokenResponse_one_of_decls, "f"));
            if (!Array.isArray(data) && typeof data == "object") {
                if ("api_key" in data && data.api_key != undefined) {
                    this.api_key = data.api_key;
                }
                if ("endpoint" in data && data.endpoint != undefined) {
                    this.endpoint = data.endpoint;
                }
                if ("valid_until" in data && data.valid_until != undefined) {
                    this.valid_until = data.valid_until;
                }
            }
        }
        get api_key() {
            return pb_1.Message.getFieldWithDefault(this, 1, "");
        }
        set api_key(value) {
            pb_1.Message.setField(this, 1, value);
        }
        get endpoint() {
            return pb_1.Message.getFieldWithDefault(this, 2, "");
        }
        set endpoint(value) {
            pb_1.Message.setField(this, 2, value);
        }
        get valid_until() {
            return pb_1.Message.getFieldWithDefault(this, 3, 0);
        }
        set valid_until(value) {
            pb_1.Message.setField(this, 3, value);
        }
        static fromObject(data) {
            const message = new _GenerateDisposableTokenResponse({});
            if (data.api_key != null) {
                message.api_key = data.api_key;
            }
            if (data.endpoint != null) {
                message.endpoint = data.endpoint;
            }
            if (data.valid_until != null) {
                message.valid_until = data.valid_until;
            }
            return message;
        }
        toObject() {
            const data = {};
            if (this.api_key != null) {
                data.api_key = this.api_key;
            }
            if (this.endpoint != null) {
                data.endpoint = this.endpoint;
            }
            if (this.valid_until != null) {
                data.valid_until = this.valid_until;
            }
            return data;
        }
        serialize(w) {
            const writer = w || new pb_1.BinaryWriter();
            if (this.api_key.length)
                writer.writeString(1, this.api_key);
            if (this.endpoint.length)
                writer.writeString(2, this.endpoint);
            if (this.valid_until != 0)
                writer.writeUint64(3, this.valid_until);
            if (!w)
                return writer.getResultBuffer();
        }
        static deserialize(bytes) {
            const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new _GenerateDisposableTokenResponse();
            while (reader.nextField()) {
                if (reader.isEndGroup())
                    break;
                switch (reader.getFieldNumber()) {
                    case 1:
                        message.api_key = reader.readString();
                        break;
                    case 2:
                        message.endpoint = reader.readString();
                        break;
                    case 3:
                        message.valid_until = reader.readUint64();
                        break;
                    default: reader.skipField();
                }
            }
            return message;
        }
        serializeBinary() {
            return this.serialize();
        }
        static deserializeBinary(bytes) {
            return _GenerateDisposableTokenResponse.deserialize(bytes);
        }
    }
    __GenerateDisposableTokenResponse_one_of_decls = new WeakMap();
    token._GenerateDisposableTokenResponse = _GenerateDisposableTokenResponse;
    class UnimplementedTokenService {
    }
    UnimplementedTokenService.definition = {
        GenerateDisposableToken: {
            path: "/token.Token/GenerateDisposableToken",
            requestStream: false,
            responseStream: false,
            requestSerialize: (message) => Buffer.from(message.serialize()),
            requestDeserialize: (bytes) => _GenerateDisposableTokenRequest.deserialize(new Uint8Array(bytes)),
            responseSerialize: (message) => Buffer.from(message.serialize()),
            responseDeserialize: (bytes) => _GenerateDisposableTokenResponse.deserialize(new Uint8Array(bytes))
        }
    };
    token.UnimplementedTokenService = UnimplementedTokenService;
    class TokenClient extends grpc_1.makeGenericClientConstructor(UnimplementedTokenService.definition, "Token", {}) {
        constructor(address, credentials, options) {
            super(address, credentials, options);
            this.GenerateDisposableToken = (message, metadata, options, callback) => {
                return super.GenerateDisposableToken(message, metadata, options, callback);
            };
        }
    }
    token.TokenClient = TokenClient;
})(token = exports.token || (exports.token = {}));
