"use strict";
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
//   protoc-gen-ts_proto  v2.11.8
//   protoc               v4.25.9
// source: google/protobuf/any.proto
Object.defineProperty(exports, "__esModule", { value: true });
exports.protoMetadata = exports.Any = exports.protobufPackage = void 0;
/* eslint-disable */
const wire_1 = require("@bufbuild/protobuf/wire");
exports.protobufPackage = "google.protobuf";
function createBaseAny() {
    return {};
}
exports.Any = {
    encode(message, writer = new wire_1.BinaryWriter()) {
        if (message.typeUrl !== undefined && message.typeUrl !== "") {
            writer.uint32(10).string(message.typeUrl);
        }
        if (message.value !== undefined && message.value.length !== 0) {
            writer.uint32(18).bytes(message.value);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
        const end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseAny();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1: {
                    if (tag !== 10) {
                        break;
                    }
                    message.typeUrl = reader.string();
                    continue;
                }
                case 2: {
                    if (tag !== 18) {
                        break;
                    }
                    message.value = Buffer.from(reader.bytes());
                    continue;
                }
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skip(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            typeUrl: isSet(object.typeUrl)
                ? globalThis.String(object.typeUrl)
                : isSet(object.type_url)
                    ? globalThis.String(object.type_url)
                    : undefined,
            value: isSet(object.value) ? Buffer.from(bytesFromBase64(object.value)) : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.typeUrl !== undefined && message.typeUrl !== "") {
            obj.typeUrl = message.typeUrl;
        }
        if (message.value !== undefined && message.value.length !== 0) {
            obj.value = base64FromBytes(message.value);
        }
        return obj;
    },
    create(base) {
        return exports.Any.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseAny();
        message.typeUrl = object.typeUrl ?? undefined;
        message.value = object.value ?? undefined;
        return message;
    },
};
exports.protoMetadata = {
    fileDescriptor: {
        "name": "google/protobuf/any.proto",
        "package": "google.protobuf",
        "dependency": [],
        "publicDependency": [],
        "weakDependency": [],
        "optionDependency": [],
        "messageType": [{
                "name": "Any",
                "field": [{
                        "name": "type_url",
                        "number": 1,
                        "label": 1,
                        "type": 9,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 0,
                        "jsonName": "typeUrl",
                        "options": undefined,
                        "proto3Optional": false,
                    }, {
                        "name": "value",
                        "number": 2,
                        "label": 1,
                        "type": 12,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 0,
                        "jsonName": "value",
                        "options": undefined,
                        "proto3Optional": false,
                    }],
                "extension": [],
                "nestedType": [],
                "enumType": [],
                "extensionRange": [],
                "oneofDecl": [],
                "options": undefined,
                "reservedRange": [],
                "reservedName": [],
                "visibility": 0,
            }],
        "enumType": [],
        "service": [],
        "extension": [],
        "options": {
            "javaPackage": "com.google.protobuf",
            "javaOuterClassname": "AnyProto",
            "javaMultipleFiles": true,
            "javaGenerateEqualsAndHash": true,
            "javaStringCheckUtf8": false,
            "optimizeFor": 1,
            "goPackage": "github.com/golang/protobuf/ptypes/any",
            "ccGenericServices": false,
            "javaGenericServices": false,
            "pyGenericServices": false,
            "deprecated": false,
            "ccEnableArenas": true,
            "objcClassPrefix": "GPB",
            "csharpNamespace": "Google.Protobuf.WellKnownTypes",
            "swiftPrefix": "",
            "phpClassPrefix": "",
            "phpNamespace": "",
            "phpMetadataNamespace": "",
            "rubyPackage": "",
            "features": undefined,
            "uninterpretedOption": [],
        },
        "sourceCodeInfo": {
            "location": [{
                    "path": [4, 0],
                    "span": [102, 0, 132, 1],
                    "leadingComments": '* `Any` contains an arbitrary serialized protocol buffer message along with a\n URL that describes the type of the serialized message.\n\n Protobuf library provides support to pack/unpack Any values in the form\n of utility functions or additional generated methods of the Any type.\n\n Example 1: Pack and unpack a message in C++.\n\n     Foo foo = ...;\n     Any any;\n     any.PackFrom(foo);\n     ...\n     if (any.UnpackTo(&foo)) {\n       ...\n     }\n\n Example 2: Pack and unpack a message in Java.\n\n     Foo foo = ...;\n     Any any = Any.pack(foo);\n     ...\n     if (any.is(Foo.class)) {\n       foo = any.unpack(Foo.class);\n     }\n\n The pack methods provided by protobuf library will by default use\n \'type.googleapis.com/full.type.name\' as the type URL and the unpack\n methods only use the fully qualified type name after the last \'/\'\n in the type URL, for example "foo.bar.com/x/y.z" will yield type\n name "y.z".\n\n\n JSON\n ====\n The JSON representation of an `Any` value uses the regular\n representation of the deserialized, embedded message, with an\n additional field `@type` which contains the type URL. Example:\n\n     package google.profile;\n     message Person {\n       string first_name = 1;\n       string last_name = 2;\n     }\n\n     {\n       "@type": "type.googleapis.com/google.profile.Person",\n       "firstName": <string>,\n       "lastName": <string>\n     }\n\n If the embedded message type is well-known and has a custom JSON\n representation, that representation will be embedded adding a field\n `value` which holds the custom JSON in addition to the `@type`\n field. Example (for message [google.protobuf.Duration][]):\n\n     {\n       "@type": "type.googleapis.com/google.protobuf.Duration",\n       "value": "1.212s"\n     }\n',
                    "trailingComments": "",
                    "leadingDetachedComments": [],
                }, {
                    "path": [4, 0, 2, 0],
                    "span": [126, 2, 22],
                    "leadingComments": '*\n A URL/resource name whose content describes the type of the\n serialized protocol buffer message.\n\n For URLs which use the schema `http`, `https`, or no schema, the\n following restrictions and interpretations apply:\n\n * If no schema is provided, `https` is assumed.\n * The last segment of the URL\'s path must represent the fully\n   qualified name of the type (as in `path/google.protobuf.Duration`).\n   The name should be in a canonical form (e.g., leading "." is\n   not accepted).\n * An HTTP GET on the URL must yield a [google.protobuf.Type][]\n   value in binary format, or produce an error.\n * Applications are allowed to cache lookup results based on the\n   URL, or have them precompiled into a binary to avoid any\n   lookup. Therefore, binary compatibility needs to be preserved\n   on changes to types. (Use versioned type names to manage\n   breaking changes.)\n\n Schemas other than `http`, `https` (or the empty schema) might be\n used with implementation specific semantics.\n',
                    "trailingComments": "",
                    "leadingDetachedComments": [],
                }, {
                    "path": [4, 0, 2, 1],
                    "span": [131, 2, 18],
                    "leadingComments": "*\n Must be a valid serialized protocol buffer of the above specified type.\n",
                    "trailingComments": "",
                    "leadingDetachedComments": [],
                }],
        },
        "syntax": "proto3",
        "edition": 0,
    },
    references: { ".google.protobuf.Any": exports.Any },
    dependencies: [],
};
function bytesFromBase64(b64) {
    return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
}
function base64FromBytes(arr) {
    return globalThis.Buffer.from(arr).toString("base64");
}
function isSet(value) {
    return value !== null && value !== undefined;
}
//# sourceMappingURL=any.js.map