// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
//   protoc-gen-ts_proto  v1.181.1
//   protoc               v3.21.12
// source: ImgDetections.proto
/* eslint-disable */
import Long from "long";
import _m0 from "protobufjs/minimal";
import { ImgTransformation, Timestamp } from "./common";
export const protobufPackage = "dai.proto.img_detections";
function createBaseImgDetections() {
    return { sequenceNum: 0, ts: undefined, tsDevice: undefined, detections: [], transformation: undefined };
}
export const ImgDetections = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.sequenceNum !== 0) {
            writer.uint32(8).int64(message.sequenceNum);
        }
        if (message.ts !== undefined) {
            Timestamp.encode(message.ts, writer.uint32(18).fork()).ldelim();
        }
        if (message.tsDevice !== undefined) {
            Timestamp.encode(message.tsDevice, writer.uint32(26).fork()).ldelim();
        }
        for (const v of message.detections) {
            ImgDetection.encode(v, writer.uint32(34).fork()).ldelim();
        }
        if (message.transformation !== undefined) {
            ImgTransformation.encode(message.transformation, writer.uint32(42).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseImgDetections();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 8) {
                        break;
                    }
                    message.sequenceNum = longToNumber(reader.int64());
                    continue;
                case 2:
                    if (tag !== 18) {
                        break;
                    }
                    message.ts = Timestamp.decode(reader, reader.uint32());
                    continue;
                case 3:
                    if (tag !== 26) {
                        break;
                    }
                    message.tsDevice = Timestamp.decode(reader, reader.uint32());
                    continue;
                case 4:
                    if (tag !== 34) {
                        break;
                    }
                    message.detections.push(ImgDetection.decode(reader, reader.uint32()));
                    continue;
                case 5:
                    if (tag !== 42) {
                        break;
                    }
                    message.transformation = ImgTransformation.decode(reader, reader.uint32());
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            sequenceNum: isSet(object.sequenceNum) ? globalThis.Number(object.sequenceNum) : 0,
            ts: isSet(object.ts) ? Timestamp.fromJSON(object.ts) : undefined,
            tsDevice: isSet(object.tsDevice) ? Timestamp.fromJSON(object.tsDevice) : undefined,
            detections: globalThis.Array.isArray(object?.detections)
                ? object.detections.map((e) => ImgDetection.fromJSON(e))
                : [],
            transformation: isSet(object.transformation) ? ImgTransformation.fromJSON(object.transformation) : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.sequenceNum !== 0) {
            obj.sequenceNum = Math.round(message.sequenceNum);
        }
        if (message.ts !== undefined) {
            obj.ts = Timestamp.toJSON(message.ts);
        }
        if (message.tsDevice !== undefined) {
            obj.tsDevice = Timestamp.toJSON(message.tsDevice);
        }
        if (message.detections?.length) {
            obj.detections = message.detections.map((e) => ImgDetection.toJSON(e));
        }
        if (message.transformation !== undefined) {
            obj.transformation = ImgTransformation.toJSON(message.transformation);
        }
        return obj;
    },
    create(base) {
        return ImgDetections.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseImgDetections();
        message.sequenceNum = object.sequenceNum ?? 0;
        message.ts = (object.ts !== undefined && object.ts !== null) ? Timestamp.fromPartial(object.ts) : undefined;
        message.tsDevice = (object.tsDevice !== undefined && object.tsDevice !== null)
            ? Timestamp.fromPartial(object.tsDevice)
            : undefined;
        message.detections = object.detections?.map((e) => ImgDetection.fromPartial(e)) || [];
        message.transformation = (object.transformation !== undefined && object.transformation !== null)
            ? ImgTransformation.fromPartial(object.transformation)
            : undefined;
        return message;
    },
};
function createBaseImgDetection() {
    return { label: 0, confidence: 0, xmin: 0, ymin: 0, xmax: 0, ymax: 0, labelName: "" };
}
export const ImgDetection = {
    encode(message, writer = _m0.Writer.create()) {
        if (message.label !== 0) {
            writer.uint32(8).uint32(message.label);
        }
        if (message.confidence !== 0) {
            writer.uint32(21).float(message.confidence);
        }
        if (message.xmin !== 0) {
            writer.uint32(29).float(message.xmin);
        }
        if (message.ymin !== 0) {
            writer.uint32(37).float(message.ymin);
        }
        if (message.xmax !== 0) {
            writer.uint32(45).float(message.xmax);
        }
        if (message.ymax !== 0) {
            writer.uint32(53).float(message.ymax);
        }
        if (message.labelName !== "") {
            writer.uint32(58).string(message.labelName);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseImgDetection();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    if (tag !== 8) {
                        break;
                    }
                    message.label = reader.uint32();
                    continue;
                case 2:
                    if (tag !== 21) {
                        break;
                    }
                    message.confidence = reader.float();
                    continue;
                case 3:
                    if (tag !== 29) {
                        break;
                    }
                    message.xmin = reader.float();
                    continue;
                case 4:
                    if (tag !== 37) {
                        break;
                    }
                    message.ymin = reader.float();
                    continue;
                case 5:
                    if (tag !== 45) {
                        break;
                    }
                    message.xmax = reader.float();
                    continue;
                case 6:
                    if (tag !== 53) {
                        break;
                    }
                    message.ymax = reader.float();
                    continue;
                case 7:
                    if (tag !== 58) {
                        break;
                    }
                    message.labelName = reader.string();
                    continue;
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skipType(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            label: isSet(object.label) ? globalThis.Number(object.label) : 0,
            confidence: isSet(object.confidence) ? globalThis.Number(object.confidence) : 0,
            xmin: isSet(object.xmin) ? globalThis.Number(object.xmin) : 0,
            ymin: isSet(object.ymin) ? globalThis.Number(object.ymin) : 0,
            xmax: isSet(object.xmax) ? globalThis.Number(object.xmax) : 0,
            ymax: isSet(object.ymax) ? globalThis.Number(object.ymax) : 0,
            labelName: isSet(object.labelName) ? globalThis.String(object.labelName) : "",
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.label !== 0) {
            obj.label = Math.round(message.label);
        }
        if (message.confidence !== 0) {
            obj.confidence = message.confidence;
        }
        if (message.xmin !== 0) {
            obj.xmin = message.xmin;
        }
        if (message.ymin !== 0) {
            obj.ymin = message.ymin;
        }
        if (message.xmax !== 0) {
            obj.xmax = message.xmax;
        }
        if (message.ymax !== 0) {
            obj.ymax = message.ymax;
        }
        if (message.labelName !== "") {
            obj.labelName = message.labelName;
        }
        return obj;
    },
    create(base) {
        return ImgDetection.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseImgDetection();
        message.label = object.label ?? 0;
        message.confidence = object.confidence ?? 0;
        message.xmin = object.xmin ?? 0;
        message.ymin = object.ymin ?? 0;
        message.xmax = object.xmax ?? 0;
        message.ymax = object.ymax ?? 0;
        message.labelName = object.labelName ?? "";
        return message;
    },
};
function longToNumber(long) {
    if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) {
        throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
    }
    if (long.lt(globalThis.Number.MIN_SAFE_INTEGER)) {
        throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER");
    }
    return long.toNumber();
}
if (_m0.util.Long !== Long) {
    _m0.util.Long = Long;
    _m0.configure();
}
function isSet(value) {
    return value !== null && value !== undefined;
}
export const protobufName = "ImgDetections";
//# sourceMappingURL=ImgDetections.js.map