import { WireType } from "@protobuf-ts/runtime";
import { UnknownFieldHandler } from "@protobuf-ts/runtime";
import { reflectionMergePartial } from "@protobuf-ts/runtime";
import { MessageType } from "@protobuf-ts/runtime";
/**
 * K-SCHED-001: Six-value scheduling judgement state enum.
 *
 * @generated from protobuf enum nimi.runtime.v1.SchedulingState
 */
export var SchedulingState;
(function (SchedulingState) {
    /**
     * @generated from protobuf enum value: SCHEDULING_STATE_UNSPECIFIED = 0;
     */
    SchedulingState[SchedulingState["UNSPECIFIED"] = 0] = "UNSPECIFIED";
    /**
     * @generated from protobuf enum value: SCHEDULING_STATE_RUNNABLE = 1;
     */
    SchedulingState[SchedulingState["RUNNABLE"] = 1] = "RUNNABLE";
    /**
     * @generated from protobuf enum value: SCHEDULING_STATE_QUEUE_REQUIRED = 2;
     */
    SchedulingState[SchedulingState["QUEUE_REQUIRED"] = 2] = "QUEUE_REQUIRED";
    /**
     * @generated from protobuf enum value: SCHEDULING_STATE_PREEMPTION_RISK = 3;
     */
    SchedulingState[SchedulingState["PREEMPTION_RISK"] = 3] = "PREEMPTION_RISK";
    /**
     * @generated from protobuf enum value: SCHEDULING_STATE_SLOWDOWN_RISK = 4;
     */
    SchedulingState[SchedulingState["SLOWDOWN_RISK"] = 4] = "SLOWDOWN_RISK";
    /**
     * @generated from protobuf enum value: SCHEDULING_STATE_DENIED = 5;
     */
    SchedulingState[SchedulingState["DENIED"] = 5] = "DENIED";
    /**
     * @generated from protobuf enum value: SCHEDULING_STATE_UNKNOWN = 6;
     */
    SchedulingState[SchedulingState["UNKNOWN"] = 6] = "UNKNOWN";
})(SchedulingState || (SchedulingState = {}));
// @generated message type with reflection information, may provide speed optimized methods
class SchedulingOccupancySnapshot$Type extends MessageType {
    constructor() {
        super("nimi.runtime.v1.SchedulingOccupancySnapshot", [
            { no: 1, name: "global_used", kind: "scalar", T: 5 /*ScalarType.INT32*/ },
            { no: 2, name: "global_cap", kind: "scalar", T: 5 /*ScalarType.INT32*/ },
            { no: 3, name: "app_used", kind: "scalar", T: 5 /*ScalarType.INT32*/ },
            { no: 4, name: "app_cap", kind: "scalar", T: 5 /*ScalarType.INT32*/ }
        ]);
    }
    create(value) {
        const message = globalThis.Object.create((this.messagePrototype));
        message.globalUsed = 0;
        message.globalCap = 0;
        message.appUsed = 0;
        message.appCap = 0;
        if (value !== undefined)
            reflectionMergePartial(this, message, value);
        return message;
    }
    internalBinaryRead(reader, length, options, target) {
        let message = target ?? this.create(), end = reader.pos + length;
        while (reader.pos < end) {
            let [fieldNo, wireType] = reader.tag();
            switch (fieldNo) {
                case /* int32 global_used */ 1:
                    message.globalUsed = reader.int32();
                    break;
                case /* int32 global_cap */ 2:
                    message.globalCap = reader.int32();
                    break;
                case /* int32 app_used */ 3:
                    message.appUsed = reader.int32();
                    break;
                case /* int32 app_cap */ 4:
                    message.appCap = reader.int32();
                    break;
                default:
                    let u = options.readUnknownField;
                    if (u === "throw")
                        throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
                    let d = reader.skip(wireType);
                    if (u !== false)
                        (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
            }
        }
        return message;
    }
    internalBinaryWrite(message, writer, options) {
        /* int32 global_used = 1; */
        if (message.globalUsed !== 0)
            writer.tag(1, WireType.Varint).int32(message.globalUsed);
        /* int32 global_cap = 2; */
        if (message.globalCap !== 0)
            writer.tag(2, WireType.Varint).int32(message.globalCap);
        /* int32 app_used = 3; */
        if (message.appUsed !== 0)
            writer.tag(3, WireType.Varint).int32(message.appUsed);
        /* int32 app_cap = 4; */
        if (message.appCap !== 0)
            writer.tag(4, WireType.Varint).int32(message.appCap);
        let u = options.writeUnknownFields;
        if (u !== false)
            (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
        return writer;
    }
}
/**
 * @generated MessageType for protobuf message nimi.runtime.v1.SchedulingOccupancySnapshot
 */
export const SchedulingOccupancySnapshot = new SchedulingOccupancySnapshot$Type();
// @generated message type with reflection information, may provide speed optimized methods
class SchedulingJudgement$Type extends MessageType {
    constructor() {
        super("nimi.runtime.v1.SchedulingJudgement", [
            { no: 1, name: "state", kind: "enum", T: () => ["nimi.runtime.v1.SchedulingState", SchedulingState, "SCHEDULING_STATE_"] },
            { no: 2, name: "detail", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
            { no: 3, name: "occupancy", kind: "message", T: () => SchedulingOccupancySnapshot },
            { no: 4, name: "resource_warnings", kind: "scalar", repeat: 2 /*RepeatType.UNPACKED*/, T: 9 /*ScalarType.STRING*/ }
        ]);
    }
    create(value) {
        const message = globalThis.Object.create((this.messagePrototype));
        message.state = 0;
        message.detail = "";
        message.resourceWarnings = [];
        if (value !== undefined)
            reflectionMergePartial(this, message, value);
        return message;
    }
    internalBinaryRead(reader, length, options, target) {
        let message = target ?? this.create(), end = reader.pos + length;
        while (reader.pos < end) {
            let [fieldNo, wireType] = reader.tag();
            switch (fieldNo) {
                case /* nimi.runtime.v1.SchedulingState state */ 1:
                    message.state = reader.int32();
                    break;
                case /* string detail */ 2:
                    message.detail = reader.string();
                    break;
                case /* nimi.runtime.v1.SchedulingOccupancySnapshot occupancy */ 3:
                    message.occupancy = SchedulingOccupancySnapshot.internalBinaryRead(reader, reader.uint32(), options, message.occupancy);
                    break;
                case /* repeated string resource_warnings */ 4:
                    message.resourceWarnings.push(reader.string());
                    break;
                default:
                    let u = options.readUnknownField;
                    if (u === "throw")
                        throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
                    let d = reader.skip(wireType);
                    if (u !== false)
                        (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
            }
        }
        return message;
    }
    internalBinaryWrite(message, writer, options) {
        /* nimi.runtime.v1.SchedulingState state = 1; */
        if (message.state !== 0)
            writer.tag(1, WireType.Varint).int32(message.state);
        /* string detail = 2; */
        if (message.detail !== "")
            writer.tag(2, WireType.LengthDelimited).string(message.detail);
        /* nimi.runtime.v1.SchedulingOccupancySnapshot occupancy = 3; */
        if (message.occupancy)
            SchedulingOccupancySnapshot.internalBinaryWrite(message.occupancy, writer.tag(3, WireType.LengthDelimited).fork(), options).join();
        /* repeated string resource_warnings = 4; */
        for (let i = 0; i < message.resourceWarnings.length; i++)
            writer.tag(4, WireType.LengthDelimited).string(message.resourceWarnings[i]);
        let u = options.writeUnknownFields;
        if (u !== false)
            (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
        return writer;
    }
}
/**
 * @generated MessageType for protobuf message nimi.runtime.v1.SchedulingJudgement
 */
export const SchedulingJudgement = new SchedulingJudgement$Type();
// @generated message type with reflection information, may provide speed optimized methods
class SchedulingResourceHint$Type extends MessageType {
    constructor() {
        super("nimi.runtime.v1.SchedulingResourceHint", [
            { no: 1, name: "estimated_vram_bytes", kind: "scalar", T: 3 /*ScalarType.INT64*/ },
            { no: 2, name: "estimated_ram_bytes", kind: "scalar", T: 3 /*ScalarType.INT64*/ },
            { no: 3, name: "estimated_disk_bytes", kind: "scalar", T: 3 /*ScalarType.INT64*/ },
            { no: 4, name: "engine", kind: "scalar", T: 9 /*ScalarType.STRING*/ }
        ]);
    }
    create(value) {
        const message = globalThis.Object.create((this.messagePrototype));
        message.estimatedVramBytes = "0";
        message.estimatedRamBytes = "0";
        message.estimatedDiskBytes = "0";
        message.engine = "";
        if (value !== undefined)
            reflectionMergePartial(this, message, value);
        return message;
    }
    internalBinaryRead(reader, length, options, target) {
        let message = target ?? this.create(), end = reader.pos + length;
        while (reader.pos < end) {
            let [fieldNo, wireType] = reader.tag();
            switch (fieldNo) {
                case /* int64 estimated_vram_bytes */ 1:
                    message.estimatedVramBytes = reader.int64().toString();
                    break;
                case /* int64 estimated_ram_bytes */ 2:
                    message.estimatedRamBytes = reader.int64().toString();
                    break;
                case /* int64 estimated_disk_bytes */ 3:
                    message.estimatedDiskBytes = reader.int64().toString();
                    break;
                case /* string engine */ 4:
                    message.engine = reader.string();
                    break;
                default:
                    let u = options.readUnknownField;
                    if (u === "throw")
                        throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
                    let d = reader.skip(wireType);
                    if (u !== false)
                        (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
            }
        }
        return message;
    }
    internalBinaryWrite(message, writer, options) {
        /* int64 estimated_vram_bytes = 1; */
        if (message.estimatedVramBytes !== "0")
            writer.tag(1, WireType.Varint).int64(message.estimatedVramBytes);
        /* int64 estimated_ram_bytes = 2; */
        if (message.estimatedRamBytes !== "0")
            writer.tag(2, WireType.Varint).int64(message.estimatedRamBytes);
        /* int64 estimated_disk_bytes = 3; */
        if (message.estimatedDiskBytes !== "0")
            writer.tag(3, WireType.Varint).int64(message.estimatedDiskBytes);
        /* string engine = 4; */
        if (message.engine !== "")
            writer.tag(4, WireType.LengthDelimited).string(message.engine);
        let u = options.writeUnknownFields;
        if (u !== false)
            (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
        return writer;
    }
}
/**
 * @generated MessageType for protobuf message nimi.runtime.v1.SchedulingResourceHint
 */
export const SchedulingResourceHint = new SchedulingResourceHint$Type();
// @generated message type with reflection information, may provide speed optimized methods
class SchedulingEvaluationTarget$Type extends MessageType {
    constructor() {
        super("nimi.runtime.v1.SchedulingEvaluationTarget", [
            { no: 1, name: "capability", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
            { no: 2, name: "mod_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
            { no: 3, name: "profile_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
            { no: 4, name: "resource_hint", kind: "message", T: () => SchedulingResourceHint }
        ]);
    }
    create(value) {
        const message = globalThis.Object.create((this.messagePrototype));
        message.capability = "";
        message.modId = "";
        message.profileId = "";
        if (value !== undefined)
            reflectionMergePartial(this, message, value);
        return message;
    }
    internalBinaryRead(reader, length, options, target) {
        let message = target ?? this.create(), end = reader.pos + length;
        while (reader.pos < end) {
            let [fieldNo, wireType] = reader.tag();
            switch (fieldNo) {
                case /* string capability */ 1:
                    message.capability = reader.string();
                    break;
                case /* string mod_id */ 2:
                    message.modId = reader.string();
                    break;
                case /* string profile_id */ 3:
                    message.profileId = reader.string();
                    break;
                case /* nimi.runtime.v1.SchedulingResourceHint resource_hint */ 4:
                    message.resourceHint = SchedulingResourceHint.internalBinaryRead(reader, reader.uint32(), options, message.resourceHint);
                    break;
                default:
                    let u = options.readUnknownField;
                    if (u === "throw")
                        throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
                    let d = reader.skip(wireType);
                    if (u !== false)
                        (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
            }
        }
        return message;
    }
    internalBinaryWrite(message, writer, options) {
        /* string capability = 1; */
        if (message.capability !== "")
            writer.tag(1, WireType.LengthDelimited).string(message.capability);
        /* string mod_id = 2; */
        if (message.modId !== "")
            writer.tag(2, WireType.LengthDelimited).string(message.modId);
        /* string profile_id = 3; */
        if (message.profileId !== "")
            writer.tag(3, WireType.LengthDelimited).string(message.profileId);
        /* nimi.runtime.v1.SchedulingResourceHint resource_hint = 4; */
        if (message.resourceHint)
            SchedulingResourceHint.internalBinaryWrite(message.resourceHint, writer.tag(4, WireType.LengthDelimited).fork(), options).join();
        let u = options.writeUnknownFields;
        if (u !== false)
            (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
        return writer;
    }
}
/**
 * @generated MessageType for protobuf message nimi.runtime.v1.SchedulingEvaluationTarget
 */
export const SchedulingEvaluationTarget = new SchedulingEvaluationTarget$Type();
// @generated message type with reflection information, may provide speed optimized methods
class SchedulingTargetJudgement$Type extends MessageType {
    constructor() {
        super("nimi.runtime.v1.SchedulingTargetJudgement", [
            { no: 1, name: "target", kind: "message", T: () => SchedulingEvaluationTarget },
            { no: 2, name: "judgement", kind: "message", T: () => SchedulingJudgement }
        ]);
    }
    create(value) {
        const message = globalThis.Object.create((this.messagePrototype));
        if (value !== undefined)
            reflectionMergePartial(this, message, value);
        return message;
    }
    internalBinaryRead(reader, length, options, target) {
        let message = target ?? this.create(), end = reader.pos + length;
        while (reader.pos < end) {
            let [fieldNo, wireType] = reader.tag();
            switch (fieldNo) {
                case /* nimi.runtime.v1.SchedulingEvaluationTarget target */ 1:
                    message.target = SchedulingEvaluationTarget.internalBinaryRead(reader, reader.uint32(), options, message.target);
                    break;
                case /* nimi.runtime.v1.SchedulingJudgement judgement */ 2:
                    message.judgement = SchedulingJudgement.internalBinaryRead(reader, reader.uint32(), options, message.judgement);
                    break;
                default:
                    let u = options.readUnknownField;
                    if (u === "throw")
                        throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
                    let d = reader.skip(wireType);
                    if (u !== false)
                        (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
            }
        }
        return message;
    }
    internalBinaryWrite(message, writer, options) {
        /* nimi.runtime.v1.SchedulingEvaluationTarget target = 1; */
        if (message.target)
            SchedulingEvaluationTarget.internalBinaryWrite(message.target, writer.tag(1, WireType.LengthDelimited).fork(), options).join();
        /* nimi.runtime.v1.SchedulingJudgement judgement = 2; */
        if (message.judgement)
            SchedulingJudgement.internalBinaryWrite(message.judgement, writer.tag(2, WireType.LengthDelimited).fork(), options).join();
        let u = options.writeUnknownFields;
        if (u !== false)
            (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
        return writer;
    }
}
/**
 * @generated MessageType for protobuf message nimi.runtime.v1.SchedulingTargetJudgement
 */
export const SchedulingTargetJudgement = new SchedulingTargetJudgement$Type();
// @generated message type with reflection information, may provide speed optimized methods
class PeekSchedulingRequest$Type extends MessageType {
    constructor() {
        super("nimi.runtime.v1.PeekSchedulingRequest", [
            { no: 1, name: "app_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
            { no: 2, name: "targets", kind: "message", repeat: 2 /*RepeatType.UNPACKED*/, T: () => SchedulingEvaluationTarget }
        ]);
    }
    create(value) {
        const message = globalThis.Object.create((this.messagePrototype));
        message.appId = "";
        message.targets = [];
        if (value !== undefined)
            reflectionMergePartial(this, message, value);
        return message;
    }
    internalBinaryRead(reader, length, options, target) {
        let message = target ?? this.create(), end = reader.pos + length;
        while (reader.pos < end) {
            let [fieldNo, wireType] = reader.tag();
            switch (fieldNo) {
                case /* string app_id */ 1:
                    message.appId = reader.string();
                    break;
                case /* repeated nimi.runtime.v1.SchedulingEvaluationTarget targets */ 2:
                    message.targets.push(SchedulingEvaluationTarget.internalBinaryRead(reader, reader.uint32(), options));
                    break;
                default:
                    let u = options.readUnknownField;
                    if (u === "throw")
                        throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
                    let d = reader.skip(wireType);
                    if (u !== false)
                        (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
            }
        }
        return message;
    }
    internalBinaryWrite(message, writer, options) {
        /* string app_id = 1; */
        if (message.appId !== "")
            writer.tag(1, WireType.LengthDelimited).string(message.appId);
        /* repeated nimi.runtime.v1.SchedulingEvaluationTarget targets = 2; */
        for (let i = 0; i < message.targets.length; i++)
            SchedulingEvaluationTarget.internalBinaryWrite(message.targets[i], writer.tag(2, WireType.LengthDelimited).fork(), options).join();
        let u = options.writeUnknownFields;
        if (u !== false)
            (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
        return writer;
    }
}
/**
 * @generated MessageType for protobuf message nimi.runtime.v1.PeekSchedulingRequest
 */
export const PeekSchedulingRequest = new PeekSchedulingRequest$Type();
// @generated message type with reflection information, may provide speed optimized methods
class PeekSchedulingResponse$Type extends MessageType {
    constructor() {
        super("nimi.runtime.v1.PeekSchedulingResponse", [
            { no: 1, name: "occupancy", kind: "message", T: () => SchedulingOccupancySnapshot },
            { no: 2, name: "aggregate_judgement", kind: "message", T: () => SchedulingJudgement },
            { no: 3, name: "target_judgements", kind: "message", repeat: 2 /*RepeatType.UNPACKED*/, T: () => SchedulingTargetJudgement }
        ]);
    }
    create(value) {
        const message = globalThis.Object.create((this.messagePrototype));
        message.targetJudgements = [];
        if (value !== undefined)
            reflectionMergePartial(this, message, value);
        return message;
    }
    internalBinaryRead(reader, length, options, target) {
        let message = target ?? this.create(), end = reader.pos + length;
        while (reader.pos < end) {
            let [fieldNo, wireType] = reader.tag();
            switch (fieldNo) {
                case /* nimi.runtime.v1.SchedulingOccupancySnapshot occupancy */ 1:
                    message.occupancy = SchedulingOccupancySnapshot.internalBinaryRead(reader, reader.uint32(), options, message.occupancy);
                    break;
                case /* nimi.runtime.v1.SchedulingJudgement aggregate_judgement */ 2:
                    message.aggregateJudgement = SchedulingJudgement.internalBinaryRead(reader, reader.uint32(), options, message.aggregateJudgement);
                    break;
                case /* repeated nimi.runtime.v1.SchedulingTargetJudgement target_judgements */ 3:
                    message.targetJudgements.push(SchedulingTargetJudgement.internalBinaryRead(reader, reader.uint32(), options));
                    break;
                default:
                    let u = options.readUnknownField;
                    if (u === "throw")
                        throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
                    let d = reader.skip(wireType);
                    if (u !== false)
                        (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
            }
        }
        return message;
    }
    internalBinaryWrite(message, writer, options) {
        /* nimi.runtime.v1.SchedulingOccupancySnapshot occupancy = 1; */
        if (message.occupancy)
            SchedulingOccupancySnapshot.internalBinaryWrite(message.occupancy, writer.tag(1, WireType.LengthDelimited).fork(), options).join();
        /* nimi.runtime.v1.SchedulingJudgement aggregate_judgement = 2; */
        if (message.aggregateJudgement)
            SchedulingJudgement.internalBinaryWrite(message.aggregateJudgement, writer.tag(2, WireType.LengthDelimited).fork(), options).join();
        /* repeated nimi.runtime.v1.SchedulingTargetJudgement target_judgements = 3; */
        for (let i = 0; i < message.targetJudgements.length; i++)
            SchedulingTargetJudgement.internalBinaryWrite(message.targetJudgements[i], writer.tag(3, WireType.LengthDelimited).fork(), options).join();
        let u = options.writeUnknownFields;
        if (u !== false)
            (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
        return writer;
    }
}
/**
 * @generated MessageType for protobuf message nimi.runtime.v1.PeekSchedulingResponse
 */
export const PeekSchedulingResponse = new PeekSchedulingResponse$Type();
//# sourceMappingURL=ai_scheduling.js.map