"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/amount.proto
Object.defineProperty(exports, "__esModule", { value: true });
exports.protoMetadata = exports.Amount = exports.VAT = exports.protobufPackage = void 0;
/* eslint-disable */
const wire_1 = require("@bufbuild/protobuf/wire");
const currency_1 = require("./currency");
const options_1 = require("./options");
const tax_1 = require("./tax");
exports.protobufPackage = "io.restorecommerce.amount";
function createBaseVAT() {
    return {};
}
exports.VAT = {
    encode(message, writer = new wire_1.BinaryWriter()) {
        if (message.taxId !== undefined) {
            writer.uint32(10).string(message.taxId);
        }
        if (message.vat !== undefined) {
            writer.uint32(17).double(message.vat);
        }
        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 = createBaseVAT();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1: {
                    if (tag !== 10) {
                        break;
                    }
                    message.taxId = reader.string();
                    continue;
                }
                case 2: {
                    if (tag !== 17) {
                        break;
                    }
                    message.vat = reader.double();
                    continue;
                }
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skip(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            taxId: isSet(object.taxId)
                ? globalThis.String(object.taxId)
                : isSet(object.tax_id)
                    ? globalThis.String(object.tax_id)
                    : undefined,
            vat: isSet(object.vat) ? globalThis.Number(object.vat) : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.taxId !== undefined) {
            obj.taxId = message.taxId;
        }
        if (message.vat !== undefined) {
            obj.vat = message.vat;
        }
        return obj;
    },
    create(base) {
        return exports.VAT.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseVAT();
        message.taxId = object.taxId ?? undefined;
        message.vat = object.vat ?? undefined;
        return message;
    },
};
function createBaseAmount() {
    return {};
}
exports.Amount = {
    encode(message, writer = new wire_1.BinaryWriter()) {
        if (message.currencyId !== undefined) {
            writer.uint32(10).string(message.currencyId);
        }
        if (message.gross !== undefined) {
            writer.uint32(17).double(message.gross);
        }
        if (message.net !== undefined) {
            writer.uint32(25).double(message.net);
        }
        if (message.vats !== undefined && message.vats.length !== 0) {
            for (const v of message.vats) {
                exports.VAT.encode(v, writer.uint32(34).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 = createBaseAmount();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1: {
                    if (tag !== 10) {
                        break;
                    }
                    message.currencyId = reader.string();
                    continue;
                }
                case 2: {
                    if (tag !== 17) {
                        break;
                    }
                    message.gross = reader.double();
                    continue;
                }
                case 3: {
                    if (tag !== 25) {
                        break;
                    }
                    message.net = reader.double();
                    continue;
                }
                case 4: {
                    if (tag !== 34) {
                        break;
                    }
                    if (message.vats === undefined) {
                        message.vats = [];
                    }
                    const el = exports.VAT.decode(reader, reader.uint32());
                    if (el !== undefined) {
                        message.vats.push(el);
                    }
                    continue;
                }
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skip(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            currencyId: isSet(object.currencyId)
                ? globalThis.String(object.currencyId)
                : isSet(object.currency_id)
                    ? globalThis.String(object.currency_id)
                    : undefined,
            gross: isSet(object.gross) ? globalThis.Number(object.gross) : undefined,
            net: isSet(object.net) ? globalThis.Number(object.net) : undefined,
            vats: globalThis.Array.isArray(object?.vats) ? object.vats.map((e) => exports.VAT.fromJSON(e)) : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.currencyId !== undefined) {
            obj.currencyId = message.currencyId;
        }
        if (message.gross !== undefined) {
            obj.gross = message.gross;
        }
        if (message.net !== undefined) {
            obj.net = message.net;
        }
        if (message.vats?.length) {
            obj.vats = message.vats.map((e) => exports.VAT.toJSON(e));
        }
        return obj;
    },
    create(base) {
        return exports.Amount.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseAmount();
        message.currencyId = object.currencyId ?? undefined;
        message.gross = object.gross ?? undefined;
        message.net = object.net ?? undefined;
        message.vats = object.vats?.map((e) => exports.VAT.fromPartial(e)) || undefined;
        return message;
    },
};
exports.protoMetadata = {
    fileDescriptor: {
        "name": "io/restorecommerce/amount.proto",
        "package": "io.restorecommerce.amount",
        "dependency": [
            "io/restorecommerce/options.proto",
            "io/restorecommerce/tax.proto",
            "io/restorecommerce/currency.proto",
        ],
        "publicDependency": [],
        "weakDependency": [],
        "optionDependency": [],
        "messageType": [{
                "name": "VAT",
                "field": [{
                        "name": "tax_id",
                        "number": 1,
                        "label": 1,
                        "type": 9,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 0,
                        "jsonName": "taxId",
                        "options": {
                            "ctype": 0,
                            "packed": false,
                            "jstype": 0,
                            "lazy": false,
                            "unverifiedLazy": false,
                            "deprecated": false,
                            "weak": false,
                            "debugRedact": false,
                            "retention": 0,
                            "targets": [],
                            "editionDefaults": [],
                            "features": undefined,
                            "featureSupport": undefined,
                            "uninterpretedOption": [],
                        },
                        "proto3Optional": true,
                    }, {
                        "name": "vat",
                        "number": 2,
                        "label": 1,
                        "type": 1,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 1,
                        "jsonName": "vat",
                        "options": undefined,
                        "proto3Optional": true,
                    }],
                "extension": [],
                "nestedType": [],
                "enumType": [],
                "extensionRange": [],
                "oneofDecl": [{ "name": "_tax_id", "options": undefined }, { "name": "_vat", "options": undefined }],
                "options": undefined,
                "reservedRange": [],
                "reservedName": [],
                "visibility": 0,
            }, {
                "name": "Amount",
                "field": [{
                        "name": "currency_id",
                        "number": 1,
                        "label": 1,
                        "type": 9,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 0,
                        "jsonName": "currencyId",
                        "options": {
                            "ctype": 0,
                            "packed": false,
                            "jstype": 0,
                            "lazy": false,
                            "unverifiedLazy": false,
                            "deprecated": false,
                            "weak": false,
                            "debugRedact": false,
                            "retention": 0,
                            "targets": [],
                            "editionDefaults": [],
                            "features": undefined,
                            "featureSupport": undefined,
                            "uninterpretedOption": [],
                        },
                        "proto3Optional": true,
                    }, {
                        "name": "gross",
                        "number": 2,
                        "label": 1,
                        "type": 1,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 1,
                        "jsonName": "gross",
                        "options": undefined,
                        "proto3Optional": true,
                    }, {
                        "name": "net",
                        "number": 3,
                        "label": 1,
                        "type": 1,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 2,
                        "jsonName": "net",
                        "options": undefined,
                        "proto3Optional": true,
                    }, {
                        "name": "vats",
                        "number": 4,
                        "label": 3,
                        "type": 11,
                        "typeName": ".io.restorecommerce.amount.VAT",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 0,
                        "jsonName": "vats",
                        "options": undefined,
                        "proto3Optional": false,
                    }],
                "extension": [],
                "nestedType": [],
                "enumType": [],
                "extensionRange": [],
                "oneofDecl": [{ "name": "_currency_id", "options": undefined }, { "name": "_gross", "options": undefined }, {
                        "name": "_net",
                        "options": undefined,
                    }],
                "options": undefined,
                "reservedRange": [],
                "reservedName": [],
                "visibility": 0,
            }],
        "enumType": [],
        "service": [],
        "extension": [],
        "options": undefined,
        "sourceCodeInfo": {
            "location": [{
                    "path": [3, 0],
                    "span": [5, 0, 42],
                    "leadingComments": " Used by resolvers\n",
                    "trailingComments": "",
                    "leadingDetachedComments": [],
                }],
        },
        "syntax": "proto3",
        "edition": 0,
    },
    references: { ".io.restorecommerce.amount.VAT": exports.VAT, ".io.restorecommerce.amount.Amount": exports.Amount },
    dependencies: [options_1.protoMetadata, tax_1.protoMetadata, currency_1.protoMetadata],
    options: {
        messages: {
            "VAT": {
                fields: {
                    "tax_id": {
                        "resolver": options_1.Resolver.decode(Buffer.from("ChsuaW8ucmVzdG9yZWNvbW1lcmNlLnRheC5UYXgSC21hc3Rlcl9kYXRhGgN0YXgiBFJlYWQqA3RheA==", "base64")),
                    },
                },
            },
            "Amount": {
                fields: {
                    "currency_id": {
                        "resolver": options_1.Resolver.decode(Buffer.from("CiUuaW8ucmVzdG9yZWNvbW1lcmNlLmN1cnJlbmN5LkN1cnJlbmN5EgttYXN0ZXJfZGF0YRoIY3VycmVuY3kiBFJlYWQqCGN1cnJlbmN5", "base64")),
                    },
                },
            },
        },
    },
};
function isSet(value) {
    return value !== null && value !== undefined;
}
//# sourceMappingURL=amount.js.map