"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.VisionServiceClient = exports.VisionServiceService = exports.FeatureResult = exports.AnalyzeResult = exports.BatchAnalyzeResponse = exports.FeatureTextDetectionConfig = exports.FeatureClassificationConfig = exports.Feature = exports.AnalyzeSpec = exports.BatchAnalyzeRequest = exports.feature_TypeToJSON = exports.feature_TypeFromJSON = exports.Feature_Type = exports.protobufPackage = void 0;
/* eslint-disable */
const long_1 = __importDefault(require("long"));
const grpc_js_1 = require("@grpc/grpc-js");
const minimal_1 = __importDefault(require("protobufjs/minimal"));
const status_1 = require("../../../../../google/rpc/status");
const text_detection_1 = require("../../../../../yandex/cloud/ai/vision/v1/text_detection");
const classification_1 = require("../../../../../yandex/cloud/ai/vision/v1/classification");
const face_detection_1 = require("../../../../../yandex/cloud/ai/vision/v1/face_detection");
const image_copy_search_1 = require("../../../../../yandex/cloud/ai/vision/v1/image_copy_search");
exports.protobufPackage = 'yandex.cloud.ai.vision.v1';
var Feature_Type;
(function (Feature_Type) {
    Feature_Type[Feature_Type["TYPE_UNSPECIFIED"] = 0] = "TYPE_UNSPECIFIED";
    /** TEXT_DETECTION - Text detection (OCR) feature. */
    Feature_Type[Feature_Type["TEXT_DETECTION"] = 1] = "TEXT_DETECTION";
    /** CLASSIFICATION - Classification feature. */
    Feature_Type[Feature_Type["CLASSIFICATION"] = 2] = "CLASSIFICATION";
    /** FACE_DETECTION - Face detection feature. */
    Feature_Type[Feature_Type["FACE_DETECTION"] = 3] = "FACE_DETECTION";
    /** IMAGE_COPY_SEARCH - Image copy search. */
    Feature_Type[Feature_Type["IMAGE_COPY_SEARCH"] = 4] = "IMAGE_COPY_SEARCH";
    Feature_Type[Feature_Type["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(Feature_Type = exports.Feature_Type || (exports.Feature_Type = {}));
function feature_TypeFromJSON(object) {
    switch (object) {
        case 0:
        case 'TYPE_UNSPECIFIED':
            return Feature_Type.TYPE_UNSPECIFIED;
        case 1:
        case 'TEXT_DETECTION':
            return Feature_Type.TEXT_DETECTION;
        case 2:
        case 'CLASSIFICATION':
            return Feature_Type.CLASSIFICATION;
        case 3:
        case 'FACE_DETECTION':
            return Feature_Type.FACE_DETECTION;
        case 4:
        case 'IMAGE_COPY_SEARCH':
            return Feature_Type.IMAGE_COPY_SEARCH;
        case -1:
        case 'UNRECOGNIZED':
        default:
            return Feature_Type.UNRECOGNIZED;
    }
}
exports.feature_TypeFromJSON = feature_TypeFromJSON;
function feature_TypeToJSON(object) {
    switch (object) {
        case Feature_Type.TYPE_UNSPECIFIED:
            return 'TYPE_UNSPECIFIED';
        case Feature_Type.TEXT_DETECTION:
            return 'TEXT_DETECTION';
        case Feature_Type.CLASSIFICATION:
            return 'CLASSIFICATION';
        case Feature_Type.FACE_DETECTION:
            return 'FACE_DETECTION';
        case Feature_Type.IMAGE_COPY_SEARCH:
            return 'IMAGE_COPY_SEARCH';
        default:
            return 'UNKNOWN';
    }
}
exports.feature_TypeToJSON = feature_TypeToJSON;
const baseBatchAnalyzeRequest = { folderId: '' };
exports.BatchAnalyzeRequest = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        for (const v of message.analyzeSpecs) {
            exports.AnalyzeSpec.encode(v, writer.uint32(10).fork()).ldelim();
        }
        if (message.folderId !== '') {
            writer.uint32(18).string(message.folderId);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseBatchAnalyzeRequest);
        message.analyzeSpecs = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.analyzeSpecs.push(exports.AnalyzeSpec.decode(reader, reader.uint32()));
                    break;
                case 2:
                    message.folderId = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseBatchAnalyzeRequest);
        message.analyzeSpecs = ((_a = object.analyzeSpecs) !== null && _a !== void 0 ? _a : []).map((e) => exports.AnalyzeSpec.fromJSON(e));
        message.folderId =
            object.folderId !== undefined && object.folderId !== null
                ? String(object.folderId)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        if (message.analyzeSpecs) {
            obj.analyzeSpecs = message.analyzeSpecs.map((e) => e ? exports.AnalyzeSpec.toJSON(e) : undefined);
        }
        else {
            obj.analyzeSpecs = [];
        }
        message.folderId !== undefined && (obj.folderId = message.folderId);
        return obj;
    },
    fromPartial(object) {
        var _a, _b;
        const message = Object.assign({}, baseBatchAnalyzeRequest);
        message.analyzeSpecs = ((_a = object.analyzeSpecs) === null || _a === void 0 ? void 0 : _a.map((e) => exports.AnalyzeSpec.fromPartial(e))) || [];
        message.folderId = (_b = object.folderId) !== null && _b !== void 0 ? _b : '';
        return message;
    },
};
const baseAnalyzeSpec = { mimeType: '' };
exports.AnalyzeSpec = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.content !== undefined) {
            writer.uint32(10).bytes(message.content);
        }
        if (message.signature !== undefined) {
            writer.uint32(42).string(message.signature);
        }
        for (const v of message.features) {
            exports.Feature.encode(v, writer.uint32(26).fork()).ldelim();
        }
        if (message.mimeType !== '') {
            writer.uint32(34).string(message.mimeType);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseAnalyzeSpec);
        message.features = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.content = reader.bytes();
                    break;
                case 5:
                    message.signature = reader.string();
                    break;
                case 3:
                    message.features.push(exports.Feature.decode(reader, reader.uint32()));
                    break;
                case 4:
                    message.mimeType = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseAnalyzeSpec);
        message.content =
            object.content !== undefined && object.content !== null
                ? Buffer.from(bytesFromBase64(object.content))
                : undefined;
        message.signature =
            object.signature !== undefined && object.signature !== null
                ? String(object.signature)
                : undefined;
        message.features = ((_a = object.features) !== null && _a !== void 0 ? _a : []).map((e) => exports.Feature.fromJSON(e));
        message.mimeType =
            object.mimeType !== undefined && object.mimeType !== null
                ? String(object.mimeType)
                : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.content !== undefined &&
            (obj.content =
                message.content !== undefined ? base64FromBytes(message.content) : undefined);
        message.signature !== undefined && (obj.signature = message.signature);
        if (message.features) {
            obj.features = message.features.map((e) => (e ? exports.Feature.toJSON(e) : undefined));
        }
        else {
            obj.features = [];
        }
        message.mimeType !== undefined && (obj.mimeType = message.mimeType);
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c, _d;
        const message = Object.assign({}, baseAnalyzeSpec);
        message.content = (_a = object.content) !== null && _a !== void 0 ? _a : undefined;
        message.signature = (_b = object.signature) !== null && _b !== void 0 ? _b : undefined;
        message.features = ((_c = object.features) === null || _c === void 0 ? void 0 : _c.map((e) => exports.Feature.fromPartial(e))) || [];
        message.mimeType = (_d = object.mimeType) !== null && _d !== void 0 ? _d : '';
        return message;
    },
};
const baseFeature = { type: 0 };
exports.Feature = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.type !== 0) {
            writer.uint32(8).int32(message.type);
        }
        if (message.classificationConfig !== undefined) {
            exports.FeatureClassificationConfig.encode(message.classificationConfig, writer.uint32(18).fork()).ldelim();
        }
        if (message.textDetectionConfig !== undefined) {
            exports.FeatureTextDetectionConfig.encode(message.textDetectionConfig, writer.uint32(26).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseFeature);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.type = reader.int32();
                    break;
                case 2:
                    message.classificationConfig = exports.FeatureClassificationConfig.decode(reader, reader.uint32());
                    break;
                case 3:
                    message.textDetectionConfig = exports.FeatureTextDetectionConfig.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseFeature);
        message.type =
            object.type !== undefined && object.type !== null
                ? feature_TypeFromJSON(object.type)
                : 0;
        message.classificationConfig =
            object.classificationConfig !== undefined && object.classificationConfig !== null
                ? exports.FeatureClassificationConfig.fromJSON(object.classificationConfig)
                : undefined;
        message.textDetectionConfig =
            object.textDetectionConfig !== undefined && object.textDetectionConfig !== null
                ? exports.FeatureTextDetectionConfig.fromJSON(object.textDetectionConfig)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.type !== undefined && (obj.type = feature_TypeToJSON(message.type));
        message.classificationConfig !== undefined &&
            (obj.classificationConfig = message.classificationConfig
                ? exports.FeatureClassificationConfig.toJSON(message.classificationConfig)
                : undefined);
        message.textDetectionConfig !== undefined &&
            (obj.textDetectionConfig = message.textDetectionConfig
                ? exports.FeatureTextDetectionConfig.toJSON(message.textDetectionConfig)
                : undefined);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseFeature);
        message.type = (_a = object.type) !== null && _a !== void 0 ? _a : 0;
        message.classificationConfig =
            object.classificationConfig !== undefined && object.classificationConfig !== null
                ? exports.FeatureClassificationConfig.fromPartial(object.classificationConfig)
                : undefined;
        message.textDetectionConfig =
            object.textDetectionConfig !== undefined && object.textDetectionConfig !== null
                ? exports.FeatureTextDetectionConfig.fromPartial(object.textDetectionConfig)
                : undefined;
        return message;
    },
};
const baseFeatureClassificationConfig = { model: '' };
exports.FeatureClassificationConfig = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.model !== '') {
            writer.uint32(10).string(message.model);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseFeatureClassificationConfig);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.model = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseFeatureClassificationConfig);
        message.model =
            object.model !== undefined && object.model !== null ? String(object.model) : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.model !== undefined && (obj.model = message.model);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseFeatureClassificationConfig);
        message.model = (_a = object.model) !== null && _a !== void 0 ? _a : '';
        return message;
    },
};
const baseFeatureTextDetectionConfig = { languageCodes: '', model: '' };
exports.FeatureTextDetectionConfig = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        for (const v of message.languageCodes) {
            writer.uint32(10).string(v);
        }
        if (message.model !== '') {
            writer.uint32(18).string(message.model);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseFeatureTextDetectionConfig);
        message.languageCodes = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.languageCodes.push(reader.string());
                    break;
                case 2:
                    message.model = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseFeatureTextDetectionConfig);
        message.languageCodes = ((_a = object.languageCodes) !== null && _a !== void 0 ? _a : []).map((e) => String(e));
        message.model =
            object.model !== undefined && object.model !== null ? String(object.model) : '';
        return message;
    },
    toJSON(message) {
        const obj = {};
        if (message.languageCodes) {
            obj.languageCodes = message.languageCodes.map((e) => e);
        }
        else {
            obj.languageCodes = [];
        }
        message.model !== undefined && (obj.model = message.model);
        return obj;
    },
    fromPartial(object) {
        var _a, _b;
        const message = Object.assign({}, baseFeatureTextDetectionConfig);
        message.languageCodes = ((_a = object.languageCodes) === null || _a === void 0 ? void 0 : _a.map((e) => e)) || [];
        message.model = (_b = object.model) !== null && _b !== void 0 ? _b : '';
        return message;
    },
};
const baseBatchAnalyzeResponse = {};
exports.BatchAnalyzeResponse = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        for (const v of message.results) {
            exports.AnalyzeResult.encode(v, writer.uint32(10).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseBatchAnalyzeResponse);
        message.results = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.results.push(exports.AnalyzeResult.decode(reader, reader.uint32()));
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseBatchAnalyzeResponse);
        message.results = ((_a = object.results) !== null && _a !== void 0 ? _a : []).map((e) => exports.AnalyzeResult.fromJSON(e));
        return message;
    },
    toJSON(message) {
        const obj = {};
        if (message.results) {
            obj.results = message.results.map((e) => (e ? exports.AnalyzeResult.toJSON(e) : undefined));
        }
        else {
            obj.results = [];
        }
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseBatchAnalyzeResponse);
        message.results = ((_a = object.results) === null || _a === void 0 ? void 0 : _a.map((e) => exports.AnalyzeResult.fromPartial(e))) || [];
        return message;
    },
};
const baseAnalyzeResult = {};
exports.AnalyzeResult = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        for (const v of message.results) {
            exports.FeatureResult.encode(v, writer.uint32(18).fork()).ldelim();
        }
        if (message.error !== undefined) {
            status_1.Status.encode(message.error, writer.uint32(10).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseAnalyzeResult);
        message.results = [];
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 2:
                    message.results.push(exports.FeatureResult.decode(reader, reader.uint32()));
                    break;
                case 1:
                    message.error = status_1.Status.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        var _a;
        const message = Object.assign({}, baseAnalyzeResult);
        message.results = ((_a = object.results) !== null && _a !== void 0 ? _a : []).map((e) => exports.FeatureResult.fromJSON(e));
        message.error =
            object.error !== undefined && object.error !== null
                ? status_1.Status.fromJSON(object.error)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        if (message.results) {
            obj.results = message.results.map((e) => (e ? exports.FeatureResult.toJSON(e) : undefined));
        }
        else {
            obj.results = [];
        }
        message.error !== undefined &&
            (obj.error = message.error ? status_1.Status.toJSON(message.error) : undefined);
        return obj;
    },
    fromPartial(object) {
        var _a;
        const message = Object.assign({}, baseAnalyzeResult);
        message.results = ((_a = object.results) === null || _a === void 0 ? void 0 : _a.map((e) => exports.FeatureResult.fromPartial(e))) || [];
        message.error =
            object.error !== undefined && object.error !== null
                ? status_1.Status.fromPartial(object.error)
                : undefined;
        return message;
    },
};
const baseFeatureResult = {};
exports.FeatureResult = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.textDetection !== undefined) {
            text_detection_1.TextAnnotation.encode(message.textDetection, writer.uint32(18).fork()).ldelim();
        }
        if (message.classification !== undefined) {
            classification_1.ClassAnnotation.encode(message.classification, writer.uint32(26).fork()).ldelim();
        }
        if (message.faceDetection !== undefined) {
            face_detection_1.FaceAnnotation.encode(message.faceDetection, writer.uint32(34).fork()).ldelim();
        }
        if (message.imageCopySearch !== undefined) {
            image_copy_search_1.ImageCopySearchAnnotation.encode(message.imageCopySearch, writer.uint32(42).fork()).ldelim();
        }
        if (message.error !== undefined) {
            status_1.Status.encode(message.error, writer.uint32(10).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseFeatureResult);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 2:
                    message.textDetection = text_detection_1.TextAnnotation.decode(reader, reader.uint32());
                    break;
                case 3:
                    message.classification = classification_1.ClassAnnotation.decode(reader, reader.uint32());
                    break;
                case 4:
                    message.faceDetection = face_detection_1.FaceAnnotation.decode(reader, reader.uint32());
                    break;
                case 5:
                    message.imageCopySearch = image_copy_search_1.ImageCopySearchAnnotation.decode(reader, reader.uint32());
                    break;
                case 1:
                    message.error = status_1.Status.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseFeatureResult);
        message.textDetection =
            object.textDetection !== undefined && object.textDetection !== null
                ? text_detection_1.TextAnnotation.fromJSON(object.textDetection)
                : undefined;
        message.classification =
            object.classification !== undefined && object.classification !== null
                ? classification_1.ClassAnnotation.fromJSON(object.classification)
                : undefined;
        message.faceDetection =
            object.faceDetection !== undefined && object.faceDetection !== null
                ? face_detection_1.FaceAnnotation.fromJSON(object.faceDetection)
                : undefined;
        message.imageCopySearch =
            object.imageCopySearch !== undefined && object.imageCopySearch !== null
                ? image_copy_search_1.ImageCopySearchAnnotation.fromJSON(object.imageCopySearch)
                : undefined;
        message.error =
            object.error !== undefined && object.error !== null
                ? status_1.Status.fromJSON(object.error)
                : undefined;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.textDetection !== undefined &&
            (obj.textDetection = message.textDetection
                ? text_detection_1.TextAnnotation.toJSON(message.textDetection)
                : undefined);
        message.classification !== undefined &&
            (obj.classification = message.classification
                ? classification_1.ClassAnnotation.toJSON(message.classification)
                : undefined);
        message.faceDetection !== undefined &&
            (obj.faceDetection = message.faceDetection
                ? face_detection_1.FaceAnnotation.toJSON(message.faceDetection)
                : undefined);
        message.imageCopySearch !== undefined &&
            (obj.imageCopySearch = message.imageCopySearch
                ? image_copy_search_1.ImageCopySearchAnnotation.toJSON(message.imageCopySearch)
                : undefined);
        message.error !== undefined &&
            (obj.error = message.error ? status_1.Status.toJSON(message.error) : undefined);
        return obj;
    },
    fromPartial(object) {
        const message = Object.assign({}, baseFeatureResult);
        message.textDetection =
            object.textDetection !== undefined && object.textDetection !== null
                ? text_detection_1.TextAnnotation.fromPartial(object.textDetection)
                : undefined;
        message.classification =
            object.classification !== undefined && object.classification !== null
                ? classification_1.ClassAnnotation.fromPartial(object.classification)
                : undefined;
        message.faceDetection =
            object.faceDetection !== undefined && object.faceDetection !== null
                ? face_detection_1.FaceAnnotation.fromPartial(object.faceDetection)
                : undefined;
        message.imageCopySearch =
            object.imageCopySearch !== undefined && object.imageCopySearch !== null
                ? image_copy_search_1.ImageCopySearchAnnotation.fromPartial(object.imageCopySearch)
                : undefined;
        message.error =
            object.error !== undefined && object.error !== null
                ? status_1.Status.fromPartial(object.error)
                : undefined;
        return message;
    },
};
/** A set of methods for the Vision service. */
exports.VisionServiceService = {
    /** Analyzes a batch of images and returns results with annotations. */
    batchAnalyze: {
        path: '/yandex.cloud.ai.vision.v1.VisionService/BatchAnalyze',
        requestStream: false,
        responseStream: false,
        requestSerialize: (value) => Buffer.from(exports.BatchAnalyzeRequest.encode(value).finish()),
        requestDeserialize: (value) => exports.BatchAnalyzeRequest.decode(value),
        responseSerialize: (value) => Buffer.from(exports.BatchAnalyzeResponse.encode(value).finish()),
        responseDeserialize: (value) => exports.BatchAnalyzeResponse.decode(value),
    },
};
exports.VisionServiceClient = (0, grpc_js_1.makeGenericClientConstructor)(exports.VisionServiceService, 'yandex.cloud.ai.vision.v1.VisionService');
var globalThis = (() => {
    if (typeof globalThis !== 'undefined')
        return globalThis;
    if (typeof self !== 'undefined')
        return self;
    if (typeof window !== 'undefined')
        return window;
    if (typeof global !== 'undefined')
        return global;
    throw 'Unable to locate global object';
})();
const atob = globalThis.atob || ((b64) => globalThis.Buffer.from(b64, 'base64').toString('binary'));
function bytesFromBase64(b64) {
    const bin = atob(b64);
    const arr = new Uint8Array(bin.length);
    for (let i = 0; i < bin.length; ++i) {
        arr[i] = bin.charCodeAt(i);
    }
    return arr;
}
const btoa = globalThis.btoa || ((bin) => globalThis.Buffer.from(bin, 'binary').toString('base64'));
function base64FromBytes(arr) {
    const bin = [];
    for (const byte of arr) {
        bin.push(String.fromCharCode(byte));
    }
    return btoa(bin.join(''));
}
if (minimal_1.default.util.Long !== long_1.default) {
    minimal_1.default.util.Long = long_1.default;
    minimal_1.default.configure();
}
