// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
//   protoc-gen-ts_proto  v2.11.8
//   protoc               v3.19.1
// source: models.proto

/* eslint-disable */
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
import {
  type CallOptions,
  type ChannelCredentials,
  Client,
  type ClientOptions,
  type ClientUnaryCall,
  type handleUnaryCall,
  makeGenericClientConstructor,
  type Metadata,
  type ServiceError,
  type UntypedServiceImplementation,
} from "@grpc/grpc-js";
import Long from "long";

export interface ListModelsRequest {
}

export interface ProviderInfo {
  discriminator: string;
  capabilities: string;
  endpoint: string;
  model: string;
  embeddingModel: string;
}

export interface ListModelsResponse {
  active: string;
  providers: ProviderInfo[];
}

function createBaseListModelsRequest(): ListModelsRequest {
  return {};
}

export const ListModelsRequest: MessageFns<ListModelsRequest> = {
  encode(_: ListModelsRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
    return writer;
  },

  decode(input: BinaryReader | Uint8Array, length?: number): ListModelsRequest {
    const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
    const end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseListModelsRequest();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skip(tag & 7);
    }
    return message;
  },

  fromJSON(_: any): ListModelsRequest {
    return {};
  },

  toJSON(_: ListModelsRequest): unknown {
    const obj: any = {};
    return obj;
  },

  create<I extends Exact<DeepPartial<ListModelsRequest>, I>>(base?: I): ListModelsRequest {
    return ListModelsRequest.fromPartial(base ?? ({} as any));
  },
  fromPartial<I extends Exact<DeepPartial<ListModelsRequest>, I>>(_: I): ListModelsRequest {
    const message = createBaseListModelsRequest();
    return message;
  },
};

function createBaseProviderInfo(): ProviderInfo {
  return { discriminator: "", capabilities: "", endpoint: "", model: "", embeddingModel: "" };
}

export const ProviderInfo: MessageFns<ProviderInfo> = {
  encode(message: ProviderInfo, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
    if (message.discriminator !== "") {
      writer.uint32(10).string(message.discriminator);
    }
    if (message.capabilities !== "") {
      writer.uint32(18).string(message.capabilities);
    }
    if (message.endpoint !== "") {
      writer.uint32(26).string(message.endpoint);
    }
    if (message.model !== "") {
      writer.uint32(34).string(message.model);
    }
    if (message.embeddingModel !== "") {
      writer.uint32(42).string(message.embeddingModel);
    }
    return writer;
  },

  decode(input: BinaryReader | Uint8Array, length?: number): ProviderInfo {
    const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
    const end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseProviderInfo();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1: {
          if (tag !== 10) {
            break;
          }

          message.discriminator = reader.string();
          continue;
        }
        case 2: {
          if (tag !== 18) {
            break;
          }

          message.capabilities = reader.string();
          continue;
        }
        case 3: {
          if (tag !== 26) {
            break;
          }

          message.endpoint = reader.string();
          continue;
        }
        case 4: {
          if (tag !== 34) {
            break;
          }

          message.model = reader.string();
          continue;
        }
        case 5: {
          if (tag !== 42) {
            break;
          }

          message.embeddingModel = reader.string();
          continue;
        }
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skip(tag & 7);
    }
    return message;
  },

  fromJSON(object: any): ProviderInfo {
    return {
      discriminator: isSet(object.discriminator) ? globalThis.String(object.discriminator) : "",
      capabilities: isSet(object.capabilities) ? globalThis.String(object.capabilities) : "",
      endpoint: isSet(object.endpoint) ? globalThis.String(object.endpoint) : "",
      model: isSet(object.model) ? globalThis.String(object.model) : "",
      embeddingModel: isSet(object.embeddingModel)
        ? globalThis.String(object.embeddingModel)
        : isSet(object.embedding_model)
        ? globalThis.String(object.embedding_model)
        : "",
    };
  },

  toJSON(message: ProviderInfo): unknown {
    const obj: any = {};
    if (message.discriminator !== "") {
      obj.discriminator = message.discriminator;
    }
    if (message.capabilities !== "") {
      obj.capabilities = message.capabilities;
    }
    if (message.endpoint !== "") {
      obj.endpoint = message.endpoint;
    }
    if (message.model !== "") {
      obj.model = message.model;
    }
    if (message.embeddingModel !== "") {
      obj.embeddingModel = message.embeddingModel;
    }
    return obj;
  },

  create<I extends Exact<DeepPartial<ProviderInfo>, I>>(base?: I): ProviderInfo {
    return ProviderInfo.fromPartial(base ?? ({} as any));
  },
  fromPartial<I extends Exact<DeepPartial<ProviderInfo>, I>>(object: I): ProviderInfo {
    const message = createBaseProviderInfo();
    message.discriminator = object.discriminator ?? "";
    message.capabilities = object.capabilities ?? "";
    message.endpoint = object.endpoint ?? "";
    message.model = object.model ?? "";
    message.embeddingModel = object.embeddingModel ?? "";
    return message;
  },
};

function createBaseListModelsResponse(): ListModelsResponse {
  return { active: "", providers: [] };
}

export const ListModelsResponse: MessageFns<ListModelsResponse> = {
  encode(message: ListModelsResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
    if (message.active !== "") {
      writer.uint32(10).string(message.active);
    }
    for (const v of message.providers) {
      ProviderInfo.encode(v!, writer.uint32(18).fork()).join();
    }
    return writer;
  },

  decode(input: BinaryReader | Uint8Array, length?: number): ListModelsResponse {
    const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
    const end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseListModelsResponse();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1: {
          if (tag !== 10) {
            break;
          }

          message.active = reader.string();
          continue;
        }
        case 2: {
          if (tag !== 18) {
            break;
          }

          message.providers.push(ProviderInfo.decode(reader, reader.uint32()));
          continue;
        }
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skip(tag & 7);
    }
    return message;
  },

  fromJSON(object: any): ListModelsResponse {
    return {
      active: isSet(object.active) ? globalThis.String(object.active) : "",
      providers: globalThis.Array.isArray(object?.providers)
        ? object.providers.map((e: any) => ProviderInfo.fromJSON(e))
        : [],
    };
  },

  toJSON(message: ListModelsResponse): unknown {
    const obj: any = {};
    if (message.active !== "") {
      obj.active = message.active;
    }
    if (message.providers?.length) {
      obj.providers = message.providers.map((e) => ProviderInfo.toJSON(e));
    }
    return obj;
  },

  create<I extends Exact<DeepPartial<ListModelsResponse>, I>>(base?: I): ListModelsResponse {
    return ListModelsResponse.fromPartial(base ?? ({} as any));
  },
  fromPartial<I extends Exact<DeepPartial<ListModelsResponse>, I>>(object: I): ListModelsResponse {
    const message = createBaseListModelsResponse();
    message.active = object.active ?? "";
    message.providers = object.providers?.map((e) => ProviderInfo.fromPartial(e)) || [];
    return message;
  },
};

export type ModelsServiceService = typeof ModelsServiceService;
export const ModelsServiceService = {
  listModels: {
    path: "/apf.ai.v1.ModelsService/ListModels" as const,
    requestStream: false as const,
    responseStream: false as const,
    requestSerialize: (value: ListModelsRequest): Buffer => Buffer.from(ListModelsRequest.encode(value).finish()),
    requestDeserialize: (value: Buffer): ListModelsRequest => ListModelsRequest.decode(value),
    responseSerialize: (value: ListModelsResponse): Buffer => Buffer.from(ListModelsResponse.encode(value).finish()),
    responseDeserialize: (value: Buffer): ListModelsResponse => ListModelsResponse.decode(value),
  },
} as const;

export interface ModelsServiceServer extends UntypedServiceImplementation {
  listModels: handleUnaryCall<ListModelsRequest, ListModelsResponse>;
}

export interface ModelsServiceClient extends Client {
  listModels(
    request: ListModelsRequest,
    callback: (error: ServiceError | null, response: ListModelsResponse) => void,
  ): ClientUnaryCall;
  listModels(
    request: ListModelsRequest,
    metadata: Metadata,
    callback: (error: ServiceError | null, response: ListModelsResponse) => void,
  ): ClientUnaryCall;
  listModels(
    request: ListModelsRequest,
    metadata: Metadata,
    options: Partial<CallOptions>,
    callback: (error: ServiceError | null, response: ListModelsResponse) => void,
  ): ClientUnaryCall;
}

export const ModelsServiceClient = makeGenericClientConstructor(
  ModelsServiceService,
  "apf.ai.v1.ModelsService",
) as unknown as {
  new (address: string, credentials: ChannelCredentials, options?: Partial<ClientOptions>): ModelsServiceClient;
  service: typeof ModelsServiceService;
  serviceName: string;
};

type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;

type DeepPartial<T> = T extends Builtin ? T
  : T extends Long ? string | number | Long : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
  : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
  : T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
  : Partial<T>;

type KeysOfUnion<T> = T extends T ? keyof T : never;
type Exact<P, I extends P> = P extends Builtin ? P
  : P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };

function isSet(value: any): boolean {
  return value !== null && value !== undefined;
}

interface MessageFns<T> {
  encode(message: T, writer?: BinaryWriter): BinaryWriter;
  decode(input: BinaryReader | Uint8Array, length?: number): T;
  fromJSON(object: any): T;
  toJSON(message: T): unknown;
  create<I extends Exact<DeepPartial<T>, I>>(base?: I): T;
  fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T;
}
