"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: io/restorecommerce/attribute.proto
Object.defineProperty(exports, "__esModule", { value: true });
exports.protoMetadata = exports.Attribute = exports.protobufPackage = void 0;
/* eslint-disable */
const wire_1 = require("@bufbuild/protobuf/wire");
exports.protobufPackage = "io.restorecommerce.attribute";
function createBaseAttribute() {
    return {};
}
exports.Attribute = {
    encode(message, writer = new wire_1.BinaryWriter()) {
        if (message.id !== undefined) {
            writer.uint32(10).string(message.id);
        }
        if (message.value !== undefined) {
            writer.uint32(18).string(message.value);
        }
        if (message.attributes !== undefined && message.attributes.length !== 0) {
            for (const v of message.attributes) {
                exports.Attribute.encode(v, writer.uint32(26).fork()).join();
            }
        }
        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 = createBaseAttribute();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1: {
                    if (tag !== 10) {
                        break;
                    }
                    message.id = reader.string();
                    continue;
                }
                case 2: {
                    if (tag !== 18) {
                        break;
                    }
                    message.value = reader.string();
                    continue;
                }
                case 3: {
                    if (tag !== 26) {
                        break;
                    }
                    if (message.attributes === undefined) {
                        message.attributes = [];
                    }
                    const el = exports.Attribute.decode(reader, reader.uint32());
                    if (el !== undefined) {
                        message.attributes.push(el);
                    }
                    continue;
                }
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skip(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            id: isSet(object.id) ? globalThis.String(object.id) : undefined,
            value: isSet(object.value) ? globalThis.String(object.value) : undefined,
            attributes: globalThis.Array.isArray(object?.attributes)
                ? object.attributes.map((e) => exports.Attribute.fromJSON(e))
                : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.id !== undefined) {
            obj.id = message.id;
        }
        if (message.value !== undefined) {
            obj.value = message.value;
        }
        if (message.attributes?.length) {
            obj.attributes = message.attributes.map((e) => exports.Attribute.toJSON(e));
        }
        return obj;
    },
    create(base) {
        return exports.Attribute.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseAttribute();
        message.id = object.id ?? undefined;
        message.value = object.value ?? undefined;
        message.attributes = object.attributes?.map((e) => exports.Attribute.fromPartial(e)) || undefined;
        return message;
    },
};
exports.protoMetadata = {
    fileDescriptor: {
        "name": "io/restorecommerce/attribute.proto",
        "package": "io.restorecommerce.attribute",
        "dependency": [],
        "publicDependency": [],
        "weakDependency": [],
        "optionDependency": [],
        "messageType": [{
                "name": "Attribute",
                "field": [{
                        "name": "id",
                        "number": 1,
                        "label": 1,
                        "type": 9,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 0,
                        "jsonName": "id",
                        "options": undefined,
                        "proto3Optional": true,
                    }, {
                        "name": "value",
                        "number": 2,
                        "label": 1,
                        "type": 9,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 1,
                        "jsonName": "value",
                        "options": undefined,
                        "proto3Optional": true,
                    }, {
                        "name": "attributes",
                        "number": 3,
                        "label": 3,
                        "type": 11,
                        "typeName": ".io.restorecommerce.attribute.Attribute",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 0,
                        "jsonName": "attributes",
                        "options": undefined,
                        "proto3Optional": false,
                    }],
                "extension": [],
                "nestedType": [],
                "enumType": [],
                "extensionRange": [],
                "oneofDecl": [{ "name": "_id", "options": undefined }, { "name": "_value", "options": undefined }],
                "options": undefined,
                "reservedRange": [],
                "reservedName": [],
                "visibility": 0,
            }],
        "enumType": [],
        "service": [],
        "extension": [],
        "options": undefined,
        "sourceCodeInfo": { "location": [] },
        "syntax": "proto3",
        "edition": 0,
    },
    references: { ".io.restorecommerce.attribute.Attribute": exports.Attribute },
    dependencies: [],
};
function isSet(value) {
    return value !== null && value !== undefined;
}
//# sourceMappingURL=attribute.js.map