"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/discount.proto
Object.defineProperty(exports, "__esModule", { value: true });
exports.protoMetadata = exports.DiscountServiceDefinition = exports.DiscountResponse = exports.DiscountListResponse = exports.DiscountList = exports.Discount_Item = exports.Discount = exports.DicountType = exports.protobufPackage = void 0;
exports.dicountTypeFromJSON = dicountTypeFromJSON;
exports.dicountTypeToJSON = dicountTypeToJSON;
exports.dicountTypeToNumber = dicountTypeToNumber;
/* eslint-disable */
const wire_1 = require("@bufbuild/protobuf/wire");
const timestamp_1 = require("../../google/protobuf/timestamp");
const auth_1 = require("./auth");
const meta_1 = require("./meta");
const options_1 = require("./options");
const resource_base_1 = require("./resource_base");
const status_1 = require("./status");
exports.protobufPackage = "io.restorecommerce.dicount";
var DicountType;
(function (DicountType) {
    /** PERCENTAGE - amount = price - price * value/100 */
    DicountType["PERCENTAGE"] = "PERCENTAGE";
    /** ABSOLUTE - amount = price - value */
    DicountType["ABSOLUTE"] = "ABSOLUTE";
    /** OVERRIDE - amount = value */
    DicountType["OVERRIDE"] = "OVERRIDE";
    DicountType["UNRECOGNIZED"] = "UNRECOGNIZED";
})(DicountType || (exports.DicountType = DicountType = {}));
function dicountTypeFromJSON(object) {
    switch (object) {
        case 0:
        case "PERCENTAGE":
            return DicountType.PERCENTAGE;
        case 1:
        case "ABSOLUTE":
            return DicountType.ABSOLUTE;
        case 2:
        case "OVERRIDE":
            return DicountType.OVERRIDE;
        case -1:
        case "UNRECOGNIZED":
        default:
            return DicountType.UNRECOGNIZED;
    }
}
function dicountTypeToJSON(object) {
    switch (object) {
        case DicountType.PERCENTAGE:
            return "PERCENTAGE";
        case DicountType.ABSOLUTE:
            return "ABSOLUTE";
        case DicountType.OVERRIDE:
            return "OVERRIDE";
        case DicountType.UNRECOGNIZED:
        default:
            return "UNRECOGNIZED";
    }
}
function dicountTypeToNumber(object) {
    switch (object) {
        case DicountType.PERCENTAGE:
            return 0;
        case DicountType.ABSOLUTE:
            return 1;
        case DicountType.OVERRIDE:
            return 2;
        case DicountType.UNRECOGNIZED:
        default:
            return -1;
    }
}
function createBaseDiscount() {
    return {};
}
exports.Discount = {
    encode(message, writer = new wire_1.BinaryWriter()) {
        if (message.id !== undefined) {
            writer.uint32(10).string(message.id);
        }
        if (message.meta !== undefined) {
            meta_1.Meta.encode(message.meta, writer.uint32(18).fork()).join();
        }
        if (message.name !== undefined) {
            writer.uint32(26).string(message.name);
        }
        if (message.description !== undefined) {
            writer.uint32(34).string(message.description);
        }
        if (message.start !== undefined) {
            timestamp_1.Timestamp.encode(toTimestamp(message.start), writer.uint32(42).fork()).join();
        }
        if (message.end !== undefined) {
            timestamp_1.Timestamp.encode(toTimestamp(message.end), writer.uint32(50).fork()).join();
        }
        if (message.discount_type !== undefined) {
            writer.uint32(56).int32(dicountTypeToNumber(message.discount_type));
        }
        if (message.value !== undefined) {
            writer.uint32(65).double(message.value);
        }
        if (message.price_group_ids !== undefined && message.price_group_ids.length !== 0) {
            for (const v of message.price_group_ids) {
                writer.uint32(74).string(v);
            }
        }
        if (message.product_category_ids !== undefined && message.product_category_ids.length !== 0) {
            for (const v of message.product_category_ids) {
                writer.uint32(82).string(v);
            }
        }
        if (message.individual_items !== undefined && message.individual_items.length !== 0) {
            for (const v of message.individual_items) {
                exports.Discount_Item.encode(v, writer.uint32(90).fork()).join();
            }
        }
        if (message.granted_Discount_ids !== undefined && message.granted_Discount_ids.length !== 0) {
            for (const v of message.granted_Discount_ids) {
                writer.uint32(98).string(v);
            }
        }
        if (message.granted_organization_ids !== undefined && message.granted_organization_ids.length !== 0) {
            for (const v of message.granted_organization_ids) {
                writer.uint32(106).string(v);
            }
        }
        if (message.granted_user_role_ids !== undefined && message.granted_user_role_ids.length !== 0) {
            for (const v of message.granted_user_role_ids) {
                writer.uint32(114).string(v);
            }
        }
        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 = createBaseDiscount();
        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.meta = meta_1.Meta.decode(reader, reader.uint32());
                    continue;
                }
                case 3: {
                    if (tag !== 26) {
                        break;
                    }
                    message.name = reader.string();
                    continue;
                }
                case 4: {
                    if (tag !== 34) {
                        break;
                    }
                    message.description = reader.string();
                    continue;
                }
                case 5: {
                    if (tag !== 42) {
                        break;
                    }
                    message.start = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
                    continue;
                }
                case 6: {
                    if (tag !== 50) {
                        break;
                    }
                    message.end = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
                    continue;
                }
                case 7: {
                    if (tag !== 56) {
                        break;
                    }
                    message.discount_type = dicountTypeFromJSON(reader.int32());
                    continue;
                }
                case 8: {
                    if (tag !== 65) {
                        break;
                    }
                    message.value = reader.double();
                    continue;
                }
                case 9: {
                    if (tag !== 74) {
                        break;
                    }
                    if (message.price_group_ids === undefined) {
                        message.price_group_ids = [];
                    }
                    const el = reader.string();
                    if (el !== undefined) {
                        message.price_group_ids.push(el);
                    }
                    continue;
                }
                case 10: {
                    if (tag !== 82) {
                        break;
                    }
                    if (message.product_category_ids === undefined) {
                        message.product_category_ids = [];
                    }
                    const el = reader.string();
                    if (el !== undefined) {
                        message.product_category_ids.push(el);
                    }
                    continue;
                }
                case 11: {
                    if (tag !== 90) {
                        break;
                    }
                    if (message.individual_items === undefined) {
                        message.individual_items = [];
                    }
                    const el = exports.Discount_Item.decode(reader, reader.uint32());
                    if (el !== undefined) {
                        message.individual_items.push(el);
                    }
                    continue;
                }
                case 12: {
                    if (tag !== 98) {
                        break;
                    }
                    if (message.granted_Discount_ids === undefined) {
                        message.granted_Discount_ids = [];
                    }
                    const el = reader.string();
                    if (el !== undefined) {
                        message.granted_Discount_ids.push(el);
                    }
                    continue;
                }
                case 13: {
                    if (tag !== 106) {
                        break;
                    }
                    if (message.granted_organization_ids === undefined) {
                        message.granted_organization_ids = [];
                    }
                    const el = reader.string();
                    if (el !== undefined) {
                        message.granted_organization_ids.push(el);
                    }
                    continue;
                }
                case 14: {
                    if (tag !== 114) {
                        break;
                    }
                    if (message.granted_user_role_ids === undefined) {
                        message.granted_user_role_ids = [];
                    }
                    const el = reader.string();
                    if (el !== undefined) {
                        message.granted_user_role_ids.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,
            meta: isSet(object.meta) ? meta_1.Meta.fromJSON(object.meta) : undefined,
            name: isSet(object.name) ? globalThis.String(object.name) : undefined,
            description: isSet(object.description) ? globalThis.String(object.description) : undefined,
            start: isSet(object.start) ? fromJsonTimestamp(object.start) : undefined,
            end: isSet(object.end) ? fromJsonTimestamp(object.end) : undefined,
            discount_type: isSet(object.discountType)
                ? dicountTypeFromJSON(object.discountType)
                : isSet(object.discount_type)
                    ? dicountTypeFromJSON(object.discount_type)
                    : undefined,
            value: isSet(object.value) ? globalThis.Number(object.value) : undefined,
            price_group_ids: globalThis.Array.isArray(object?.priceGroupIds)
                ? object.priceGroupIds.map((e) => globalThis.String(e))
                : globalThis.Array.isArray(object?.price_group_ids)
                    ? object.price_group_ids.map((e) => globalThis.String(e))
                    : undefined,
            product_category_ids: globalThis.Array.isArray(object?.productCategoryIds)
                ? object.productCategoryIds.map((e) => globalThis.String(e))
                : globalThis.Array.isArray(object?.product_category_ids)
                    ? object.product_category_ids.map((e) => globalThis.String(e))
                    : undefined,
            individual_items: globalThis.Array.isArray(object?.individualItems)
                ? object.individualItems.map((e) => exports.Discount_Item.fromJSON(e))
                : globalThis.Array.isArray(object?.individual_items)
                    ? object.individual_items.map((e) => exports.Discount_Item.fromJSON(e))
                    : undefined,
            granted_Discount_ids: globalThis.Array.isArray(object?.grantedDiscountIds)
                ? object.grantedDiscountIds.map((e) => globalThis.String(e))
                : globalThis.Array.isArray(object?.granted_Discount_ids)
                    ? object.granted_Discount_ids.map((e) => globalThis.String(e))
                    : undefined,
            granted_organization_ids: globalThis.Array.isArray(object?.grantedOrganizationIds)
                ? object.grantedOrganizationIds.map((e) => globalThis.String(e))
                : globalThis.Array.isArray(object?.granted_organization_ids)
                    ? object.granted_organization_ids.map((e) => globalThis.String(e))
                    : undefined,
            granted_user_role_ids: globalThis.Array.isArray(object?.grantedUserRoleIds)
                ? object.grantedUserRoleIds.map((e) => globalThis.String(e))
                : globalThis.Array.isArray(object?.granted_user_role_ids)
                    ? object.granted_user_role_ids.map((e) => globalThis.String(e))
                    : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.id !== undefined) {
            obj.id = message.id;
        }
        if (message.meta !== undefined) {
            obj.meta = meta_1.Meta.toJSON(message.meta);
        }
        if (message.name !== undefined) {
            obj.name = message.name;
        }
        if (message.description !== undefined) {
            obj.description = message.description;
        }
        if (message.start !== undefined) {
            obj.start = message.start.toISOString();
        }
        if (message.end !== undefined) {
            obj.end = message.end.toISOString();
        }
        if (message.discount_type !== undefined) {
            obj.discountType = dicountTypeToJSON(message.discount_type);
        }
        if (message.value !== undefined) {
            obj.value = message.value;
        }
        if (message.price_group_ids?.length) {
            obj.priceGroupIds = message.price_group_ids;
        }
        if (message.product_category_ids?.length) {
            obj.productCategoryIds = message.product_category_ids;
        }
        if (message.individual_items?.length) {
            obj.individualItems = message.individual_items.map((e) => exports.Discount_Item.toJSON(e));
        }
        if (message.granted_Discount_ids?.length) {
            obj.grantedDiscountIds = message.granted_Discount_ids;
        }
        if (message.granted_organization_ids?.length) {
            obj.grantedOrganizationIds = message.granted_organization_ids;
        }
        if (message.granted_user_role_ids?.length) {
            obj.grantedUserRoleIds = message.granted_user_role_ids;
        }
        return obj;
    },
    create(base) {
        return exports.Discount.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseDiscount();
        message.id = object.id ?? undefined;
        message.meta = (object.meta !== undefined && object.meta !== null) ? meta_1.Meta.fromPartial(object.meta) : undefined;
        message.name = object.name ?? undefined;
        message.description = object.description ?? undefined;
        message.start = object.start ?? undefined;
        message.end = object.end ?? undefined;
        message.discount_type = object.discount_type ?? undefined;
        message.value = object.value ?? undefined;
        message.price_group_ids = object.price_group_ids?.map((e) => e) || undefined;
        message.product_category_ids = object.product_category_ids?.map((e) => e) || undefined;
        message.individual_items = object.individual_items?.map((e) => exports.Discount_Item.fromPartial(e)) || undefined;
        message.granted_Discount_ids = object.granted_Discount_ids?.map((e) => e) || undefined;
        message.granted_organization_ids = object.granted_organization_ids?.map((e) => e) || undefined;
        message.granted_user_role_ids = object.granted_user_role_ids?.map((e) => e) || undefined;
        return message;
    },
};
function createBaseDiscount_Item() {
    return {};
}
exports.Discount_Item = {
    encode(message, writer = new wire_1.BinaryWriter()) {
        if (message.product_id !== undefined) {
            writer.uint32(10).string(message.product_id);
        }
        if (message.variant_ids !== undefined && message.variant_ids.length !== 0) {
            for (const v of message.variant_ids) {
                writer.uint32(18).string(v);
            }
        }
        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 = createBaseDiscount_Item();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1: {
                    if (tag !== 10) {
                        break;
                    }
                    message.product_id = reader.string();
                    continue;
                }
                case 2: {
                    if (tag !== 18) {
                        break;
                    }
                    if (message.variant_ids === undefined) {
                        message.variant_ids = [];
                    }
                    const el = reader.string();
                    if (el !== undefined) {
                        message.variant_ids.push(el);
                    }
                    continue;
                }
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skip(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            product_id: isSet(object.productId)
                ? globalThis.String(object.productId)
                : isSet(object.product_id)
                    ? globalThis.String(object.product_id)
                    : undefined,
            variant_ids: globalThis.Array.isArray(object?.variantIds)
                ? object.variantIds.map((e) => globalThis.String(e))
                : globalThis.Array.isArray(object?.variant_ids)
                    ? object.variant_ids.map((e) => globalThis.String(e))
                    : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.product_id !== undefined) {
            obj.productId = message.product_id;
        }
        if (message.variant_ids?.length) {
            obj.variantIds = message.variant_ids;
        }
        return obj;
    },
    create(base) {
        return exports.Discount_Item.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseDiscount_Item();
        message.product_id = object.product_id ?? undefined;
        message.variant_ids = object.variant_ids?.map((e) => e) || undefined;
        return message;
    },
};
function createBaseDiscountList() {
    return {};
}
exports.DiscountList = {
    encode(message, writer = new wire_1.BinaryWriter()) {
        if (message.items !== undefined && message.items.length !== 0) {
            for (const v of message.items) {
                exports.Discount.encode(v, writer.uint32(10).fork()).join();
            }
        }
        if (message.total_count !== undefined) {
            writer.uint32(16).uint32(message.total_count);
        }
        if (message.subject !== undefined) {
            auth_1.Subject.encode(message.subject, 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 = createBaseDiscountList();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1: {
                    if (tag !== 10) {
                        break;
                    }
                    if (message.items === undefined) {
                        message.items = [];
                    }
                    const el = exports.Discount.decode(reader, reader.uint32());
                    if (el !== undefined) {
                        message.items.push(el);
                    }
                    continue;
                }
                case 2: {
                    if (tag !== 16) {
                        break;
                    }
                    message.total_count = reader.uint32();
                    continue;
                }
                case 3: {
                    if (tag !== 26) {
                        break;
                    }
                    message.subject = auth_1.Subject.decode(reader, reader.uint32());
                    continue;
                }
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skip(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            items: globalThis.Array.isArray(object?.items) ? object.items.map((e) => exports.Discount.fromJSON(e)) : undefined,
            total_count: isSet(object.totalCount)
                ? globalThis.Number(object.totalCount)
                : isSet(object.total_count)
                    ? globalThis.Number(object.total_count)
                    : undefined,
            subject: isSet(object.subject) ? auth_1.Subject.fromJSON(object.subject) : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.items?.length) {
            obj.items = message.items.map((e) => exports.Discount.toJSON(e));
        }
        if (message.total_count !== undefined) {
            obj.totalCount = Math.round(message.total_count);
        }
        if (message.subject !== undefined) {
            obj.subject = auth_1.Subject.toJSON(message.subject);
        }
        return obj;
    },
    create(base) {
        return exports.DiscountList.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseDiscountList();
        message.items = object.items?.map((e) => exports.Discount.fromPartial(e)) || undefined;
        message.total_count = object.total_count ?? undefined;
        message.subject = (object.subject !== undefined && object.subject !== null)
            ? auth_1.Subject.fromPartial(object.subject)
            : undefined;
        return message;
    },
};
function createBaseDiscountListResponse() {
    return {};
}
exports.DiscountListResponse = {
    encode(message, writer = new wire_1.BinaryWriter()) {
        if (message.items !== undefined && message.items.length !== 0) {
            for (const v of message.items) {
                exports.DiscountResponse.encode(v, writer.uint32(10).fork()).join();
            }
        }
        if (message.total_count !== undefined) {
            writer.uint32(16).uint32(message.total_count);
        }
        if (message.operation_status !== undefined) {
            status_1.OperationStatus.encode(message.operation_status, 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 = createBaseDiscountListResponse();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1: {
                    if (tag !== 10) {
                        break;
                    }
                    if (message.items === undefined) {
                        message.items = [];
                    }
                    const el = exports.DiscountResponse.decode(reader, reader.uint32());
                    if (el !== undefined) {
                        message.items.push(el);
                    }
                    continue;
                }
                case 2: {
                    if (tag !== 16) {
                        break;
                    }
                    message.total_count = reader.uint32();
                    continue;
                }
                case 3: {
                    if (tag !== 26) {
                        break;
                    }
                    message.operation_status = status_1.OperationStatus.decode(reader, reader.uint32());
                    continue;
                }
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skip(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            items: globalThis.Array.isArray(object?.items)
                ? object.items.map((e) => exports.DiscountResponse.fromJSON(e))
                : undefined,
            total_count: isSet(object.totalCount)
                ? globalThis.Number(object.totalCount)
                : isSet(object.total_count)
                    ? globalThis.Number(object.total_count)
                    : undefined,
            operation_status: isSet(object.operationStatus)
                ? status_1.OperationStatus.fromJSON(object.operationStatus)
                : isSet(object.operation_status)
                    ? status_1.OperationStatus.fromJSON(object.operation_status)
                    : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.items?.length) {
            obj.items = message.items.map((e) => exports.DiscountResponse.toJSON(e));
        }
        if (message.total_count !== undefined) {
            obj.totalCount = Math.round(message.total_count);
        }
        if (message.operation_status !== undefined) {
            obj.operationStatus = status_1.OperationStatus.toJSON(message.operation_status);
        }
        return obj;
    },
    create(base) {
        return exports.DiscountListResponse.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseDiscountListResponse();
        message.items = object.items?.map((e) => exports.DiscountResponse.fromPartial(e)) || undefined;
        message.total_count = object.total_count ?? undefined;
        message.operation_status = (object.operation_status !== undefined && object.operation_status !== null)
            ? status_1.OperationStatus.fromPartial(object.operation_status)
            : undefined;
        return message;
    },
};
function createBaseDiscountResponse() {
    return {};
}
exports.DiscountResponse = {
    encode(message, writer = new wire_1.BinaryWriter()) {
        if (message.payload !== undefined) {
            exports.Discount.encode(message.payload, writer.uint32(10).fork()).join();
        }
        if (message.status !== undefined) {
            status_1.Status.encode(message.status, writer.uint32(18).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 = createBaseDiscountResponse();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1: {
                    if (tag !== 10) {
                        break;
                    }
                    message.payload = exports.Discount.decode(reader, reader.uint32());
                    continue;
                }
                case 2: {
                    if (tag !== 18) {
                        break;
                    }
                    message.status = status_1.Status.decode(reader, reader.uint32());
                    continue;
                }
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skip(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            payload: isSet(object.payload) ? exports.Discount.fromJSON(object.payload) : undefined,
            status: isSet(object.status) ? status_1.Status.fromJSON(object.status) : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.payload !== undefined) {
            obj.payload = exports.Discount.toJSON(message.payload);
        }
        if (message.status !== undefined) {
            obj.status = status_1.Status.toJSON(message.status);
        }
        return obj;
    },
    create(base) {
        return exports.DiscountResponse.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseDiscountResponse();
        message.payload = (object.payload !== undefined && object.payload !== null)
            ? exports.Discount.fromPartial(object.payload)
            : undefined;
        message.status = (object.status !== undefined && object.status !== null)
            ? status_1.Status.fromPartial(object.status)
            : undefined;
        return message;
    },
};
exports.DiscountServiceDefinition = {
    name: "DiscountService",
    fullName: "io.restorecommerce.dicount.DiscountService",
    methods: {
        read: {
            name: "Read",
            requestType: resource_base_1.ReadRequest,
            requestStream: false,
            responseType: exports.DiscountListResponse,
            responseStream: false,
            options: { _unknownFields: { 248008: [Buffer.from([1])] } },
        },
        create: {
            name: "Create",
            requestType: exports.DiscountList,
            requestStream: false,
            responseType: exports.DiscountListResponse,
            responseStream: false,
            options: {},
        },
        delete: {
            name: "Delete",
            requestType: resource_base_1.DeleteRequest,
            requestStream: false,
            responseType: resource_base_1.DeleteResponse,
            responseStream: false,
            options: {},
        },
        update: {
            name: "Update",
            requestType: exports.DiscountList,
            requestStream: false,
            responseType: exports.DiscountListResponse,
            responseStream: false,
            options: {},
        },
        upsert: {
            name: "Upsert",
            requestType: exports.DiscountList,
            requestStream: false,
            responseType: exports.DiscountListResponse,
            responseStream: false,
            options: {},
        },
    },
};
exports.protoMetadata = {
    fileDescriptor: {
        "name": "io/restorecommerce/discount.proto",
        "package": "io.restorecommerce.dicount",
        "dependency": [
            "google/protobuf/timestamp.proto",
            "io/restorecommerce/resource_base.proto",
            "io/restorecommerce/meta.proto",
            "io/restorecommerce/auth.proto",
            "io/restorecommerce/status.proto",
            "io/restorecommerce/options.proto",
        ],
        "publicDependency": [],
        "weakDependency": [],
        "optionDependency": [],
        "messageType": [{
                "name": "Discount",
                "field": [{
                        "name": "id",
                        "number": 1,
                        "label": 1,
                        "type": 9,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 0,
                        "jsonName": "id",
                        "options": undefined,
                        "proto3Optional": true,
                    }, {
                        "name": "meta",
                        "number": 2,
                        "label": 1,
                        "type": 11,
                        "typeName": ".io.restorecommerce.meta.Meta",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 1,
                        "jsonName": "meta",
                        "options": undefined,
                        "proto3Optional": true,
                    }, {
                        "name": "name",
                        "number": 3,
                        "label": 1,
                        "type": 9,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 2,
                        "jsonName": "name",
                        "options": undefined,
                        "proto3Optional": true,
                    }, {
                        "name": "description",
                        "number": 4,
                        "label": 1,
                        "type": 9,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 3,
                        "jsonName": "description",
                        "options": undefined,
                        "proto3Optional": true,
                    }, {
                        "name": "start",
                        "number": 5,
                        "label": 1,
                        "type": 11,
                        "typeName": ".google.protobuf.Timestamp",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 4,
                        "jsonName": "start",
                        "options": undefined,
                        "proto3Optional": true,
                    }, {
                        "name": "end",
                        "number": 6,
                        "label": 1,
                        "type": 11,
                        "typeName": ".google.protobuf.Timestamp",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 5,
                        "jsonName": "end",
                        "options": undefined,
                        "proto3Optional": true,
                    }, {
                        "name": "discount_type",
                        "number": 7,
                        "label": 1,
                        "type": 14,
                        "typeName": ".io.restorecommerce.dicount.DicountType",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 6,
                        "jsonName": "discountType",
                        "options": undefined,
                        "proto3Optional": true,
                    }, {
                        "name": "value",
                        "number": 8,
                        "label": 1,
                        "type": 1,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 7,
                        "jsonName": "value",
                        "options": undefined,
                        "proto3Optional": true,
                    }, {
                        "name": "price_group_ids",
                        "number": 9,
                        "label": 3,
                        "type": 9,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 0,
                        "jsonName": "priceGroupIds",
                        "options": undefined,
                        "proto3Optional": false,
                    }, {
                        "name": "product_category_ids",
                        "number": 10,
                        "label": 3,
                        "type": 9,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 0,
                        "jsonName": "productCategoryIds",
                        "options": undefined,
                        "proto3Optional": false,
                    }, {
                        "name": "individual_items",
                        "number": 11,
                        "label": 3,
                        "type": 11,
                        "typeName": ".io.restorecommerce.dicount.Discount.Item",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 0,
                        "jsonName": "individualItems",
                        "options": undefined,
                        "proto3Optional": false,
                    }, {
                        "name": "granted_Discount_ids",
                        "number": 12,
                        "label": 3,
                        "type": 9,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 0,
                        "jsonName": "grantedDiscountIds",
                        "options": undefined,
                        "proto3Optional": false,
                    }, {
                        "name": "granted_organization_ids",
                        "number": 13,
                        "label": 3,
                        "type": 9,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 0,
                        "jsonName": "grantedOrganizationIds",
                        "options": undefined,
                        "proto3Optional": false,
                    }, {
                        "name": "granted_user_role_ids",
                        "number": 14,
                        "label": 3,
                        "type": 9,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 0,
                        "jsonName": "grantedUserRoleIds",
                        "options": undefined,
                        "proto3Optional": false,
                    }],
                "extension": [],
                "nestedType": [{
                        "name": "Item",
                        "field": [{
                                "name": "product_id",
                                "number": 1,
                                "label": 1,
                                "type": 9,
                                "typeName": "",
                                "extendee": "",
                                "defaultValue": "",
                                "oneofIndex": 0,
                                "jsonName": "productId",
                                "options": undefined,
                                "proto3Optional": true,
                            }, {
                                "name": "variant_ids",
                                "number": 2,
                                "label": 3,
                                "type": 9,
                                "typeName": "",
                                "extendee": "",
                                "defaultValue": "",
                                "oneofIndex": 0,
                                "jsonName": "variantIds",
                                "options": undefined,
                                "proto3Optional": false,
                            }],
                        "extension": [],
                        "nestedType": [],
                        "enumType": [],
                        "extensionRange": [],
                        "oneofDecl": [{ "name": "_product_id", "options": undefined }],
                        "options": undefined,
                        "reservedRange": [],
                        "reservedName": [],
                        "visibility": 0,
                    }],
                "enumType": [],
                "extensionRange": [],
                "oneofDecl": [
                    { "name": "_id", "options": undefined },
                    { "name": "_meta", "options": undefined },
                    { "name": "_name", "options": undefined },
                    { "name": "_description", "options": undefined },
                    { "name": "_start", "options": undefined },
                    { "name": "_end", "options": undefined },
                    { "name": "_discount_type", "options": undefined },
                    { "name": "_value", "options": undefined },
                ],
                "options": undefined,
                "reservedRange": [],
                "reservedName": [],
                "visibility": 0,
            }, {
                "name": "DiscountList",
                "field": [{
                        "name": "items",
                        "number": 1,
                        "label": 3,
                        "type": 11,
                        "typeName": ".io.restorecommerce.dicount.Discount",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 0,
                        "jsonName": "items",
                        "options": undefined,
                        "proto3Optional": false,
                    }, {
                        "name": "total_count",
                        "number": 2,
                        "label": 1,
                        "type": 13,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 0,
                        "jsonName": "totalCount",
                        "options": undefined,
                        "proto3Optional": true,
                    }, {
                        "name": "subject",
                        "number": 3,
                        "label": 1,
                        "type": 11,
                        "typeName": ".io.restorecommerce.auth.Subject",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 1,
                        "jsonName": "subject",
                        "options": undefined,
                        "proto3Optional": true,
                    }],
                "extension": [],
                "nestedType": [],
                "enumType": [],
                "extensionRange": [],
                "oneofDecl": [{ "name": "_total_count", "options": undefined }, { "name": "_subject", "options": undefined }],
                "options": undefined,
                "reservedRange": [],
                "reservedName": [],
                "visibility": 0,
            }, {
                "name": "DiscountListResponse",
                "field": [{
                        "name": "items",
                        "number": 1,
                        "label": 3,
                        "type": 11,
                        "typeName": ".io.restorecommerce.dicount.DiscountResponse",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 0,
                        "jsonName": "items",
                        "options": undefined,
                        "proto3Optional": false,
                    }, {
                        "name": "total_count",
                        "number": 2,
                        "label": 1,
                        "type": 13,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 0,
                        "jsonName": "totalCount",
                        "options": undefined,
                        "proto3Optional": true,
                    }, {
                        "name": "operation_status",
                        "number": 3,
                        "label": 1,
                        "type": 11,
                        "typeName": ".io.restorecommerce.status.OperationStatus",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 1,
                        "jsonName": "operationStatus",
                        "options": undefined,
                        "proto3Optional": true,
                    }],
                "extension": [],
                "nestedType": [],
                "enumType": [],
                "extensionRange": [],
                "oneofDecl": [{ "name": "_total_count", "options": undefined }, {
                        "name": "_operation_status",
                        "options": undefined,
                    }],
                "options": undefined,
                "reservedRange": [],
                "reservedName": [],
                "visibility": 0,
            }, {
                "name": "DiscountResponse",
                "field": [{
                        "name": "payload",
                        "number": 1,
                        "label": 1,
                        "type": 11,
                        "typeName": ".io.restorecommerce.dicount.Discount",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 0,
                        "jsonName": "payload",
                        "options": undefined,
                        "proto3Optional": true,
                    }, {
                        "name": "status",
                        "number": 2,
                        "label": 1,
                        "type": 11,
                        "typeName": ".io.restorecommerce.status.Status",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 1,
                        "jsonName": "status",
                        "options": undefined,
                        "proto3Optional": true,
                    }],
                "extension": [],
                "nestedType": [],
                "enumType": [],
                "extensionRange": [],
                "oneofDecl": [{ "name": "_payload", "options": undefined }, { "name": "_status", "options": undefined }],
                "options": undefined,
                "reservedRange": [],
                "reservedName": [],
                "visibility": 0,
            }],
        "enumType": [{
                "name": "DicountType",
                "value": [{ "name": "PERCENTAGE", "number": 0, "options": undefined }, {
                        "name": "ABSOLUTE",
                        "number": 1,
                        "options": undefined,
                    }, { "name": "OVERRIDE", "number": 2, "options": undefined }],
                "options": undefined,
                "reservedRange": [],
                "reservedName": [],
                "visibility": 0,
            }],
        "service": [{
                "name": "DiscountService",
                "method": [{
                        "name": "Read",
                        "inputType": ".io.restorecommerce.resourcebase.ReadRequest",
                        "outputType": ".io.restorecommerce.dicount.DiscountListResponse",
                        "options": { "deprecated": false, "idempotencyLevel": 0, "features": undefined, "uninterpretedOption": [] },
                        "clientStreaming": false,
                        "serverStreaming": false,
                    }, {
                        "name": "Create",
                        "inputType": ".io.restorecommerce.dicount.DiscountList",
                        "outputType": ".io.restorecommerce.dicount.DiscountListResponse",
                        "options": undefined,
                        "clientStreaming": false,
                        "serverStreaming": false,
                    }, {
                        "name": "Delete",
                        "inputType": ".io.restorecommerce.resourcebase.DeleteRequest",
                        "outputType": ".io.restorecommerce.resourcebase.DeleteResponse",
                        "options": undefined,
                        "clientStreaming": false,
                        "serverStreaming": false,
                    }, {
                        "name": "Update",
                        "inputType": ".io.restorecommerce.dicount.DiscountList",
                        "outputType": ".io.restorecommerce.dicount.DiscountListResponse",
                        "options": undefined,
                        "clientStreaming": false,
                        "serverStreaming": false,
                    }, {
                        "name": "Upsert",
                        "inputType": ".io.restorecommerce.dicount.DiscountList",
                        "outputType": ".io.restorecommerce.dicount.DiscountListResponse",
                        "options": undefined,
                        "clientStreaming": false,
                        "serverStreaming": false,
                    }],
                "options": undefined,
            }],
        "extension": [],
        "options": undefined,
        "sourceCodeInfo": {
            "location": [{
                    "path": [6, 0],
                    "span": [15, 0, 23, 1],
                    "leadingComments": "\nMicroservice definition.\n",
                    "trailingComments": "",
                    "leadingDetachedComments": [],
                }, {
                    "path": [5, 0, 2, 0],
                    "span": [26, 2, 17],
                    "leadingComments": "",
                    "trailingComments": " amount = price - price * value/100\n",
                    "leadingDetachedComments": [],
                }, {
                    "path": [5, 0, 2, 1],
                    "span": [27, 2, 15],
                    "leadingComments": "",
                    "trailingComments": " amount = price - value\n",
                    "leadingDetachedComments": [],
                }, {
                    "path": [5, 0, 2, 2],
                    "span": [28, 2, 15],
                    "leadingComments": "",
                    "trailingComments": " amount = value\n",
                    "leadingDetachedComments": [],
                }, {
                    "path": [4, 0, 3, 0, 2, 1],
                    "span": [34, 4, 36],
                    "leadingComments": "",
                    "trailingComments": " empty to address all variants\n",
                    "leadingDetachedComments": [],
                }, {
                    "path": [4, 0, 2, 12],
                    "span": [50, 2, 48],
                    "leadingComments": "",
                    "trailingComments": " ????\n",
                    "leadingDetachedComments": [],
                }, {
                    "path": [4, 0, 2, 13],
                    "span": [51, 2, 45],
                    "leadingComments": "",
                    "trailingComments": " ????\n",
                    "leadingDetachedComments": [],
                }],
        },
        "syntax": "proto3",
        "edition": 0,
    },
    references: {
        ".io.restorecommerce.dicount.DicountType": DicountType,
        ".io.restorecommerce.dicount.Discount": exports.Discount,
        ".io.restorecommerce.dicount.Discount.Item": exports.Discount_Item,
        ".io.restorecommerce.dicount.DiscountList": exports.DiscountList,
        ".io.restorecommerce.dicount.DiscountListResponse": exports.DiscountListResponse,
        ".io.restorecommerce.dicount.DiscountResponse": exports.DiscountResponse,
    },
    dependencies: [timestamp_1.protoMetadata, resource_base_1.protoMetadata, meta_1.protoMetadata, auth_1.protoMetadata, status_1.protoMetadata, options_1.protoMetadata],
    options: { services: { "DiscountService": { methods: { "Read": { "is_query": true } } } } },
};
function toTimestamp(date) {
    const seconds = Math.trunc(date.getTime() / 1_000);
    const nanos = (date.getTime() % 1_000) * 1_000_000;
    return { seconds, nanos };
}
function fromTimestamp(t) {
    let millis = (t.seconds || 0) * 1_000;
    millis += (t.nanos || 0) / 1_000_000;
    return new globalThis.Date(millis);
}
function fromJsonTimestamp(o) {
    if (o instanceof globalThis.Date) {
        return o;
    }
    else if (typeof o === "string") {
        return new globalThis.Date(o);
    }
    else {
        return fromTimestamp(timestamp_1.Timestamp.fromJSON(o));
    }
}
function isSet(value) {
    return value !== null && value !== undefined;
}
//# sourceMappingURL=discount.js.map