// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
//   protoc-gen-ts_proto  v2.2.4
//   protoc               v3.20.3
// source: generate.proto

/* eslint-disable */
import { BinaryReader, BinaryWriter } from '@bufbuild/protobuf/wire'; 
import {
  type CallOptions,
  ChannelCredentials,
  Client,
  ClientDuplexStream,
  type ClientOptions,
  ClientReadableStream,
  type ClientUnaryCall,
  ClientWritableStream,
  Metadata as Metadata1,
  type ServiceError,
  type UntypedServiceImplementation,
  handleBidiStreamingCall,
  handleClientStreamingCall,
  handleServerStreamingCall,
  type handleUnaryCall,
  makeGenericClientConstructor,
} from '@grpc/grpc-js';

export const protobufPackage = 'studio_api_grpc';

export interface GenerateRequest {
  name: string;
}

export interface GenerateResponse {
  message: string;
}

export interface HealthCheckRequest {}

export interface HealthCheckResponse {
  healthy: boolean;
}

export interface GenerateServerStreamRequest {
  prompt: string;
  tags?: string | undefined;
  negativeTags?: string | undefined;
  title?: string | undefined;
  gptPrompt?: string | undefined;
  gptDescriptionPrompt: string;
  voiceId?: string | undefined;
  voice?: string | undefined;
  metadata: { [key: string]: string };
  modelName?: string | undefined;
  stream?: boolean | undefined;
  isRegenerate?: boolean | undefined;
  batchSize?: number | undefined;
  makeInstrumental?: boolean | undefined;
  coverImageS3Id?: string | undefined;
  creationSource?: string | undefined;
  continueClipId?: string | undefined;
  continueAt?: number | undefined;
  continuedAlignedPrompt?: string | undefined;
  mv: string;
  infillStartS?: number | undefined;
  infillEndS?: number | undefined;
  infillDurS?: number | undefined;
  includeHistory?: boolean | undefined;
  generationType: string;
  userUploadedImagesB64: string[];
  userUploadedImagesIds: string[];
  userUploadedVideoId?: string | undefined;
  artistClipId?: string | undefined;
  artistStartS?: number | undefined;
  artistEndS?: number | undefined;
  coverClipId?: string | undefined;
  personaId?: string | undefined;
  task?: string | undefined;
  editSessionId?: string | undefined;
}

export interface GenerateServerStreamRequest_MetadataEntry {
  key: string;
  value: string;
}

export interface GenerateServerStreamResponse {
  id?: string | undefined;
  clips: Clip[];
  metadata?: Metadata | undefined;
  majorModelVersion?: string | undefined;
  status?: string | undefined;
  createdAt?: string | undefined;
  batchSize?: number | undefined;
  message?: string | undefined;
}

export interface Clip {
  id?: string | undefined;
  videoUrl?: string | undefined;
  audioUrl?: string | undefined;
  imageUrl?: string | undefined;
  imageLargeUrl?: string | undefined;
  isVideoPending?: boolean | undefined;
  majorModelVersion?: string | undefined;
  modelName?: string | undefined;
  metadata?: Metadata | undefined;
  isLiked?: boolean | undefined;
  userId?: string | undefined;
  displayName?: string | undefined;
  handle?: string | undefined;
  isHandleUpdated?: boolean | undefined;
  avatarImageUrl?: string | undefined;
  isTrashed?: boolean | undefined;
  reaction?: Reaction | undefined;
  createdAt?: string | undefined;
  status?: string | undefined;
  title?: string | undefined;
  playCount?: number | undefined;
  upvoteCount?: number | undefined;
  isPublic?: boolean | undefined;
}

export interface Metadata {
  tags?: string | undefined;
  negativeTags?: string | undefined;
  prompt?: string | undefined;
  gptDescriptionPrompt?: string | undefined;
  history: HistoryItem[];
  concatHistory: HistoryItem[];
  stemFromId?: string | undefined;
  type?: string | undefined;
  duration?: number | undefined;
  refundCredits?: boolean | undefined;
  stream?: boolean | undefined;
  infill?: boolean | undefined;
  hasVocal?: boolean | undefined;
  canPublishWithVocal?: boolean | undefined;
  isAudioUploadTosAccepted?: boolean | undefined;
  errorType?: string | undefined;
  errorMessage?: string | undefined;
  configurations: { [key: string]: number };
  artistClipId?: string | undefined;
  coverClipId?: string | undefined;
  personaId?: string | undefined;
  videoToSongVideoUploadId?: string | undefined;
  videoToSongVideoUploadUrl?: string | undefined;
  videoToSongVideoOutputUrl?: string | undefined;
  imageToSongImageIds: string[];
  imageToSongImageUrls: string[];
  isImageToSong?: boolean | undefined;
  isSunoShort?: boolean | undefined;
  task?: string | undefined;
  editSessionId?: string | undefined;
}

export interface Metadata_ConfigurationsEntry {
  key: string;
  value: number;
}

export interface HistoryItem {
  id?: string | undefined;
  continueAt?: number | undefined;
  type?: string | undefined;
  source?: string | undefined;
  infill?: boolean | undefined;
}

export interface Reaction {
  playCount?: number | undefined;
  skipCount?: number | undefined;
  flagged?: boolean | undefined;
  flaggedReason?: string | undefined;
  feedbackReason?: string | undefined;
  reactionType?: string | undefined;
  clip?: string | undefined;
  updatedAt?: string | undefined;
}

function createBaseGenerateRequest(): GenerateRequest {
  return { name: '' };
}

export const GenerateRequest: MessageFns<GenerateRequest> = {
  encode(
    message: GenerateRequest,
    writer: BinaryWriter = new BinaryWriter()
  ): BinaryWriter {
    if (message.name !== '') {
      writer.uint32(10).string(message.name);
    }
    return writer;
  },

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

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

  fromJSON(object: any): GenerateRequest {
    return { name: isSet(object.name) ? globalThis.String(object.name) : '' };
  },

  toJSON(message: GenerateRequest): unknown {
    const obj: any = {};
    if (message.name !== '') {
      obj.name = message.name;
    }
    return obj;
  },

  create<I extends Exact<DeepPartial<GenerateRequest>, I>>(
    base?: I
  ): GenerateRequest {
    return GenerateRequest.fromPartial(base ?? ({} as any));
  },
  fromPartial<I extends Exact<DeepPartial<GenerateRequest>, I>>(
    object: I
  ): GenerateRequest {
    const message = createBaseGenerateRequest();
    message.name = object.name ?? '';
    return message;
  },
};

function createBaseGenerateResponse(): GenerateResponse {
  return { message: '' };
}

export const GenerateResponse: MessageFns<GenerateResponse> = {
  encode(
    message: GenerateResponse,
    writer: BinaryWriter = new BinaryWriter()
  ): BinaryWriter {
    if (message.message !== '') {
      writer.uint32(10).string(message.message);
    }
    return writer;
  },

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

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

  fromJSON(object: any): GenerateResponse {
    return {
      message: isSet(object.message) ? globalThis.String(object.message) : '',
    };
  },

  toJSON(message: GenerateResponse): unknown {
    const obj: any = {};
    if (message.message !== '') {
      obj.message = message.message;
    }
    return obj;
  },

  create<I extends Exact<DeepPartial<GenerateResponse>, I>>(
    base?: I
  ): GenerateResponse {
    return GenerateResponse.fromPartial(base ?? ({} as any));
  },
  fromPartial<I extends Exact<DeepPartial<GenerateResponse>, I>>(
    object: I
  ): GenerateResponse {
    const message = createBaseGenerateResponse();
    message.message = object.message ?? '';
    return message;
  },
};

function createBaseHealthCheckRequest(): HealthCheckRequest {
  return {};
}

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

  decode(
    input: BinaryReader | Uint8Array,
    length?: number
  ): HealthCheckRequest {
    const reader =
      input instanceof BinaryReader ? input : new BinaryReader(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseHealthCheckRequest();
    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): HealthCheckRequest {
    return {};
  },

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

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

function createBaseHealthCheckResponse(): HealthCheckResponse {
  return { healthy: false };
}

export const HealthCheckResponse: MessageFns<HealthCheckResponse> = {
  encode(
    message: HealthCheckResponse,
    writer: BinaryWriter = new BinaryWriter()
  ): BinaryWriter {
    if (message.healthy !== false) {
      writer.uint32(8).bool(message.healthy);
    }
    return writer;
  },

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

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

  fromJSON(object: any): HealthCheckResponse {
    return {
      healthy: isSet(object.healthy)
        ? globalThis.Boolean(object.healthy)
        : false,
    };
  },

  toJSON(message: HealthCheckResponse): unknown {
    const obj: any = {};
    if (message.healthy !== false) {
      obj.healthy = message.healthy;
    }
    return obj;
  },

  create<I extends Exact<DeepPartial<HealthCheckResponse>, I>>(
    base?: I
  ): HealthCheckResponse {
    return HealthCheckResponse.fromPartial(base ?? ({} as any));
  },
  fromPartial<I extends Exact<DeepPartial<HealthCheckResponse>, I>>(
    object: I
  ): HealthCheckResponse {
    const message = createBaseHealthCheckResponse();
    message.healthy = object.healthy ?? false;
    return message;
  },
};

function createBaseGenerateServerStreamRequest(): GenerateServerStreamRequest {
  return {
    prompt: '',
    tags: undefined,
    negativeTags: undefined,
    title: undefined,
    gptPrompt: undefined,
    gptDescriptionPrompt: '',
    voiceId: undefined,
    voice: undefined,
    metadata: {},
    modelName: undefined,
    stream: undefined,
    isRegenerate: undefined,
    batchSize: undefined,
    makeInstrumental: undefined,
    coverImageS3Id: undefined,
    creationSource: undefined,
    continueClipId: undefined,
    continueAt: undefined,
    continuedAlignedPrompt: undefined,
    mv: '',
    infillStartS: undefined,
    infillEndS: undefined,
    infillDurS: undefined,
    includeHistory: undefined,
    generationType: '',
    userUploadedImagesB64: [],
    userUploadedImagesIds: [],
    userUploadedVideoId: undefined,
    artistClipId: undefined,
    artistStartS: undefined,
    artistEndS: undefined,
    coverClipId: undefined,
    personaId: undefined,
    task: undefined,
    editSessionId: undefined,
  };
}

export const GenerateServerStreamRequest: MessageFns<GenerateServerStreamRequest> =
  {
    encode(
      message: GenerateServerStreamRequest,
      writer: BinaryWriter = new BinaryWriter()
    ): BinaryWriter {
      if (message.prompt !== '') {
        writer.uint32(10).string(message.prompt);
      }
      if (message.tags !== undefined) {
        writer.uint32(18).string(message.tags);
      }
      if (message.negativeTags !== undefined) {
        writer.uint32(26).string(message.negativeTags);
      }
      if (message.title !== undefined) {
        writer.uint32(34).string(message.title);
      }
      if (message.gptPrompt !== undefined) {
        writer.uint32(42).string(message.gptPrompt);
      }
      if (message.gptDescriptionPrompt !== '') {
        writer.uint32(50).string(message.gptDescriptionPrompt);
      }
      if (message.voiceId !== undefined) {
        writer.uint32(58).string(message.voiceId);
      }
      if (message.voice !== undefined) {
        writer.uint32(66).string(message.voice);
      }
      Object.entries(message.metadata).forEach(([key, value]) => {
        GenerateServerStreamRequest_MetadataEntry.encode(
          { key: key as any, value },
          writer.uint32(74).fork()
        ).join();
      });
      if (message.modelName !== undefined) {
        writer.uint32(82).string(message.modelName);
      }
      if (message.stream !== undefined) {
        writer.uint32(88).bool(message.stream);
      }
      if (message.isRegenerate !== undefined) {
        writer.uint32(96).bool(message.isRegenerate);
      }
      if (message.batchSize !== undefined) {
        writer.uint32(104).int32(message.batchSize);
      }
      if (message.makeInstrumental !== undefined) {
        writer.uint32(112).bool(message.makeInstrumental);
      }
      if (message.coverImageS3Id !== undefined) {
        writer.uint32(122).string(message.coverImageS3Id);
      }
      if (message.creationSource !== undefined) {
        writer.uint32(130).string(message.creationSource);
      }
      if (message.continueClipId !== undefined) {
        writer.uint32(138).string(message.continueClipId);
      }
      if (message.continueAt !== undefined) {
        writer.uint32(144).int32(message.continueAt);
      }
      if (message.continuedAlignedPrompt !== undefined) {
        writer.uint32(154).string(message.continuedAlignedPrompt);
      }
      if (message.mv !== '') {
        writer.uint32(162).string(message.mv);
      }
      if (message.infillStartS !== undefined) {
        writer.uint32(168).int32(message.infillStartS);
      }
      if (message.infillEndS !== undefined) {
        writer.uint32(176).int32(message.infillEndS);
      }
      if (message.infillDurS !== undefined) {
        writer.uint32(184).int32(message.infillDurS);
      }
      if (message.includeHistory !== undefined) {
        writer.uint32(192).bool(message.includeHistory);
      }
      if (message.generationType !== '') {
        writer.uint32(202).string(message.generationType);
      }
      for (const v of message.userUploadedImagesB64) {
        writer.uint32(210).string(v!);
      }
      for (const v of message.userUploadedImagesIds) {
        writer.uint32(218).string(v!);
      }
      if (message.userUploadedVideoId !== undefined) {
        writer.uint32(226).string(message.userUploadedVideoId);
      }
      if (message.artistClipId !== undefined) {
        writer.uint32(250).string(message.artistClipId);
      }
      if (message.artistStartS !== undefined) {
        writer.uint32(256).int32(message.artistStartS);
      }
      if (message.artistEndS !== undefined) {
        writer.uint32(264).int32(message.artistEndS);
      }
      if (message.coverClipId !== undefined) {
        writer.uint32(274).string(message.coverClipId);
      }
      if (message.personaId !== undefined) {
        writer.uint32(282).string(message.personaId);
      }
      if (message.task !== undefined) {
        writer.uint32(290).string(message.task);
      }
      if (message.editSessionId !== undefined) {
        writer.uint32(298).string(message.editSessionId);
      }
      return writer;
    },

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

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

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

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

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

            message.gptPrompt = reader.string();
            continue;
          }
          case 6: {
            if (tag !== 50) {
              break;
            }

            message.gptDescriptionPrompt = reader.string();
            continue;
          }
          case 7: {
            if (tag !== 58) {
              break;
            }

            message.voiceId = reader.string();
            continue;
          }
          case 8: {
            if (tag !== 66) {
              break;
            }

            message.voice = reader.string();
            continue;
          }
          case 9: {
            if (tag !== 74) {
              break;
            }

            const entry9 = GenerateServerStreamRequest_MetadataEntry.decode(
              reader,
              reader.uint32()
            );
            if (entry9.value !== undefined) {
              message.metadata[entry9.key] = entry9.value;
            }
            continue;
          }
          case 10: {
            if (tag !== 82) {
              break;
            }

            message.modelName = reader.string();
            continue;
          }
          case 11: {
            if (tag !== 88) {
              break;
            }

            message.stream = reader.bool();
            continue;
          }
          case 12: {
            if (tag !== 96) {
              break;
            }

            message.isRegenerate = reader.bool();
            continue;
          }
          case 13: {
            if (tag !== 104) {
              break;
            }

            message.batchSize = reader.int32();
            continue;
          }
          case 14: {
            if (tag !== 112) {
              break;
            }

            message.makeInstrumental = reader.bool();
            continue;
          }
          case 15: {
            if (tag !== 122) {
              break;
            }

            message.coverImageS3Id = reader.string();
            continue;
          }
          case 16: {
            if (tag !== 130) {
              break;
            }

            message.creationSource = reader.string();
            continue;
          }
          case 17: {
            if (tag !== 138) {
              break;
            }

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

            message.continueAt = reader.int32();
            continue;
          }
          case 19: {
            if (tag !== 154) {
              break;
            }

            message.continuedAlignedPrompt = reader.string();
            continue;
          }
          case 20: {
            if (tag !== 162) {
              break;
            }

            message.mv = reader.string();
            continue;
          }
          case 21: {
            if (tag !== 168) {
              break;
            }

            message.infillStartS = reader.int32();
            continue;
          }
          case 22: {
            if (tag !== 176) {
              break;
            }

            message.infillEndS = reader.int32();
            continue;
          }
          case 23: {
            if (tag !== 184) {
              break;
            }

            message.infillDurS = reader.int32();
            continue;
          }
          case 24: {
            if (tag !== 192) {
              break;
            }

            message.includeHistory = reader.bool();
            continue;
          }
          case 25: {
            if (tag !== 202) {
              break;
            }

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

            message.userUploadedImagesB64.push(reader.string());
            continue;
          }
          case 27: {
            if (tag !== 218) {
              break;
            }

            message.userUploadedImagesIds.push(reader.string());
            continue;
          }
          case 28: {
            if (tag !== 226) {
              break;
            }

            message.userUploadedVideoId = reader.string();
            continue;
          }
          case 31: {
            if (tag !== 250) {
              break;
            }

            message.artistClipId = reader.string();
            continue;
          }
          case 32: {
            if (tag !== 256) {
              break;
            }

            message.artistStartS = reader.int32();
            continue;
          }
          case 33: {
            if (tag !== 264) {
              break;
            }

            message.artistEndS = reader.int32();
            continue;
          }
          case 34: {
            if (tag !== 274) {
              break;
            }

            message.coverClipId = reader.string();
            continue;
          }
          case 35: {
            if (tag !== 282) {
              break;
            }

            message.personaId = reader.string();
            continue;
          }
          case 36: {
            if (tag !== 290) {
              break;
            }

            message.task = reader.string();
            continue;
          }
          case 37: {
            if (tag !== 298) {
              break;
            }

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

    fromJSON(object: any): GenerateServerStreamRequest {
      return {
        prompt: isSet(object.prompt) ? globalThis.String(object.prompt) : '',
        tags: isSet(object.tags) ? globalThis.String(object.tags) : undefined,
        negativeTags: isSet(object.negativeTags)
          ? globalThis.String(object.negativeTags)
          : undefined,
        title: isSet(object.title)
          ? globalThis.String(object.title)
          : undefined,
        gptPrompt: isSet(object.gptPrompt)
          ? globalThis.String(object.gptPrompt)
          : undefined,
        gptDescriptionPrompt: isSet(object.gptDescriptionPrompt)
          ? globalThis.String(object.gptDescriptionPrompt)
          : '',
        voiceId: isSet(object.voiceId)
          ? globalThis.String(object.voiceId)
          : undefined,
        voice: isSet(object.voice)
          ? globalThis.String(object.voice)
          : undefined,
        metadata: isObject(object.metadata)
          ? Object.entries(object.metadata).reduce<{ [key: string]: string }>(
              (acc, [key, value]) => {
                acc[key] = String(value);
                return acc;
              },
              {}
            )
          : {},
        modelName: isSet(object.modelName)
          ? globalThis.String(object.modelName)
          : undefined,
        stream: isSet(object.stream)
          ? globalThis.Boolean(object.stream)
          : undefined,
        isRegenerate: isSet(object.isRegenerate)
          ? globalThis.Boolean(object.isRegenerate)
          : undefined,
        batchSize: isSet(object.batchSize)
          ? globalThis.Number(object.batchSize)
          : undefined,
        makeInstrumental: isSet(object.makeInstrumental)
          ? globalThis.Boolean(object.makeInstrumental)
          : undefined,
        coverImageS3Id: isSet(object.coverImageS3Id)
          ? globalThis.String(object.coverImageS3Id)
          : undefined,
        creationSource: isSet(object.creationSource)
          ? globalThis.String(object.creationSource)
          : undefined,
        continueClipId: isSet(object.continueClipId)
          ? globalThis.String(object.continueClipId)
          : undefined,
        continueAt: isSet(object.continueAt)
          ? globalThis.Number(object.continueAt)
          : undefined,
        continuedAlignedPrompt: isSet(object.continuedAlignedPrompt)
          ? globalThis.String(object.continuedAlignedPrompt)
          : undefined,
        mv: isSet(object.mv) ? globalThis.String(object.mv) : '',
        infillStartS: isSet(object.infillStartS)
          ? globalThis.Number(object.infillStartS)
          : undefined,
        infillEndS: isSet(object.infillEndS)
          ? globalThis.Number(object.infillEndS)
          : undefined,
        infillDurS: isSet(object.infillDurS)
          ? globalThis.Number(object.infillDurS)
          : undefined,
        includeHistory: isSet(object.includeHistory)
          ? globalThis.Boolean(object.includeHistory)
          : undefined,
        generationType: isSet(object.generationType)
          ? globalThis.String(object.generationType)
          : '',
        userUploadedImagesB64: globalThis.Array.isArray(
          object?.userUploadedImagesB64
        )
          ? object.userUploadedImagesB64.map((e: any) => globalThis.String(e))
          : [],
        userUploadedImagesIds: globalThis.Array.isArray(
          object?.userUploadedImagesIds
        )
          ? object.userUploadedImagesIds.map((e: any) => globalThis.String(e))
          : [],
        userUploadedVideoId: isSet(object.userUploadedVideoId)
          ? globalThis.String(object.userUploadedVideoId)
          : undefined,
        artistClipId: isSet(object.artistClipId)
          ? globalThis.String(object.artistClipId)
          : undefined,
        artistStartS: isSet(object.artistStartS)
          ? globalThis.Number(object.artistStartS)
          : undefined,
        artistEndS: isSet(object.artistEndS)
          ? globalThis.Number(object.artistEndS)
          : undefined,
        coverClipId: isSet(object.coverClipId)
          ? globalThis.String(object.coverClipId)
          : undefined,
        personaId: isSet(object.personaId)
          ? globalThis.String(object.personaId)
          : undefined,
        task: isSet(object.task) ? globalThis.String(object.task) : undefined,
        editSessionId: isSet(object.editSessionId)
          ? globalThis.String(object.editSessionId)
          : undefined,
      };
    },

    toJSON(message: GenerateServerStreamRequest): unknown {
      const obj: any = {};
      if (message.prompt !== '') {
        obj.prompt = message.prompt;
      }
      if (message.tags !== undefined) {
        obj.tags = message.tags;
      }
      if (message.negativeTags !== undefined) {
        obj.negativeTags = message.negativeTags;
      }
      if (message.title !== undefined) {
        obj.title = message.title;
      }
      if (message.gptPrompt !== undefined) {
        obj.gptPrompt = message.gptPrompt;
      }
      if (message.gptDescriptionPrompt !== '') {
        obj.gptDescriptionPrompt = message.gptDescriptionPrompt;
      }
      if (message.voiceId !== undefined) {
        obj.voiceId = message.voiceId;
      }
      if (message.voice !== undefined) {
        obj.voice = message.voice;
      }
      if (message.metadata) {
        const entries = Object.entries(message.metadata);
        if (entries.length > 0) {
          obj.metadata = {};
          entries.forEach(([k, v]) => {
            obj.metadata[k] = v;
          });
        }
      }
      if (message.modelName !== undefined) {
        obj.modelName = message.modelName;
      }
      if (message.stream !== undefined) {
        obj.stream = message.stream;
      }
      if (message.isRegenerate !== undefined) {
        obj.isRegenerate = message.isRegenerate;
      }
      if (message.batchSize !== undefined) {
        obj.batchSize = Math.round(message.batchSize);
      }
      if (message.makeInstrumental !== undefined) {
        obj.makeInstrumental = message.makeInstrumental;
      }
      if (message.coverImageS3Id !== undefined) {
        obj.coverImageS3Id = message.coverImageS3Id;
      }
      if (message.creationSource !== undefined) {
        obj.creationSource = message.creationSource;
      }
      if (message.continueClipId !== undefined) {
        obj.continueClipId = message.continueClipId;
      }
      if (message.continueAt !== undefined) {
        obj.continueAt = Math.round(message.continueAt);
      }
      if (message.continuedAlignedPrompt !== undefined) {
        obj.continuedAlignedPrompt = message.continuedAlignedPrompt;
      }
      if (message.mv !== '') {
        obj.mv = message.mv;
      }
      if (message.infillStartS !== undefined) {
        obj.infillStartS = Math.round(message.infillStartS);
      }
      if (message.infillEndS !== undefined) {
        obj.infillEndS = Math.round(message.infillEndS);
      }
      if (message.infillDurS !== undefined) {
        obj.infillDurS = Math.round(message.infillDurS);
      }
      if (message.includeHistory !== undefined) {
        obj.includeHistory = message.includeHistory;
      }
      if (message.generationType !== '') {
        obj.generationType = message.generationType;
      }
      if (message.userUploadedImagesB64?.length) {
        obj.userUploadedImagesB64 = message.userUploadedImagesB64;
      }
      if (message.userUploadedImagesIds?.length) {
        obj.userUploadedImagesIds = message.userUploadedImagesIds;
      }
      if (message.userUploadedVideoId !== undefined) {
        obj.userUploadedVideoId = message.userUploadedVideoId;
      }
      if (message.artistClipId !== undefined) {
        obj.artistClipId = message.artistClipId;
      }
      if (message.artistStartS !== undefined) {
        obj.artistStartS = Math.round(message.artistStartS);
      }
      if (message.artistEndS !== undefined) {
        obj.artistEndS = Math.round(message.artistEndS);
      }
      if (message.coverClipId !== undefined) {
        obj.coverClipId = message.coverClipId;
      }
      if (message.personaId !== undefined) {
        obj.personaId = message.personaId;
      }
      if (message.task !== undefined) {
        obj.task = message.task;
      }
      if (message.editSessionId !== undefined) {
        obj.editSessionId = message.editSessionId;
      }
      return obj;
    },

    create<I extends Exact<DeepPartial<GenerateServerStreamRequest>, I>>(
      base?: I
    ): GenerateServerStreamRequest {
      return GenerateServerStreamRequest.fromPartial(base ?? ({} as any));
    },
    fromPartial<I extends Exact<DeepPartial<GenerateServerStreamRequest>, I>>(
      object: I
    ): GenerateServerStreamRequest {
      const message = createBaseGenerateServerStreamRequest();
      message.prompt = object.prompt ?? '';
      message.tags = object.tags ?? undefined;
      message.negativeTags = object.negativeTags ?? undefined;
      message.title = object.title ?? undefined;
      message.gptPrompt = object.gptPrompt ?? undefined;
      message.gptDescriptionPrompt = object.gptDescriptionPrompt ?? '';
      message.voiceId = object.voiceId ?? undefined;
      message.voice = object.voice ?? undefined;
      message.metadata = Object.entries(object.metadata ?? {}).reduce<{
        [key: string]: string;
      }>((acc, [key, value]) => {
        if (value !== undefined) {
          acc[key] = globalThis.String(value);
        }
        return acc;
      }, {});
      message.modelName = object.modelName ?? undefined;
      message.stream = object.stream ?? undefined;
      message.isRegenerate = object.isRegenerate ?? undefined;
      message.batchSize = object.batchSize ?? undefined;
      message.makeInstrumental = object.makeInstrumental ?? undefined;
      message.coverImageS3Id = object.coverImageS3Id ?? undefined;
      message.creationSource = object.creationSource ?? undefined;
      message.continueClipId = object.continueClipId ?? undefined;
      message.continueAt = object.continueAt ?? undefined;
      message.continuedAlignedPrompt =
        object.continuedAlignedPrompt ?? undefined;
      message.mv = object.mv ?? '';
      message.infillStartS = object.infillStartS ?? undefined;
      message.infillEndS = object.infillEndS ?? undefined;
      message.infillDurS = object.infillDurS ?? undefined;
      message.includeHistory = object.includeHistory ?? undefined;
      message.generationType = object.generationType ?? '';
      message.userUploadedImagesB64 =
        object.userUploadedImagesB64?.map((e) => e) || [];
      message.userUploadedImagesIds =
        object.userUploadedImagesIds?.map((e) => e) || [];
      message.userUploadedVideoId = object.userUploadedVideoId ?? undefined;
      message.artistClipId = object.artistClipId ?? undefined;
      message.artistStartS = object.artistStartS ?? undefined;
      message.artistEndS = object.artistEndS ?? undefined;
      message.coverClipId = object.coverClipId ?? undefined;
      message.personaId = object.personaId ?? undefined;
      message.task = object.task ?? undefined;
      message.editSessionId = object.editSessionId ?? undefined;
      return message;
    },
  };

function createBaseGenerateServerStreamRequest_MetadataEntry(): GenerateServerStreamRequest_MetadataEntry {
  return { key: '', value: '' };
}

export const GenerateServerStreamRequest_MetadataEntry: MessageFns<GenerateServerStreamRequest_MetadataEntry> =
  {
    encode(
      message: GenerateServerStreamRequest_MetadataEntry,
      writer: BinaryWriter = new BinaryWriter()
    ): BinaryWriter {
      if (message.key !== '') {
        writer.uint32(10).string(message.key);
      }
      if (message.value !== '') {
        writer.uint32(18).string(message.value);
      }
      return writer;
    },

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

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

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

    fromJSON(object: any): GenerateServerStreamRequest_MetadataEntry {
      return {
        key: isSet(object.key) ? globalThis.String(object.key) : '',
        value: isSet(object.value) ? globalThis.String(object.value) : '',
      };
    },

    toJSON(message: GenerateServerStreamRequest_MetadataEntry): unknown {
      const obj: any = {};
      if (message.key !== '') {
        obj.key = message.key;
      }
      if (message.value !== '') {
        obj.value = message.value;
      }
      return obj;
    },

    create<
      I extends Exact<
        DeepPartial<GenerateServerStreamRequest_MetadataEntry>,
        I
      >,
    >(base?: I): GenerateServerStreamRequest_MetadataEntry {
      return GenerateServerStreamRequest_MetadataEntry.fromPartial(
        base ?? ({} as any)
      );
    },
    fromPartial<
      I extends Exact<
        DeepPartial<GenerateServerStreamRequest_MetadataEntry>,
        I
      >,
    >(object: I): GenerateServerStreamRequest_MetadataEntry {
      const message = createBaseGenerateServerStreamRequest_MetadataEntry();
      message.key = object.key ?? '';
      message.value = object.value ?? '';
      return message;
    },
  };

function createBaseGenerateServerStreamResponse(): GenerateServerStreamResponse {
  return {
    id: undefined,
    clips: [],
    metadata: undefined,
    majorModelVersion: undefined,
    status: undefined,
    createdAt: undefined,
    batchSize: undefined,
    message: undefined,
  };
}

export const GenerateServerStreamResponse: MessageFns<GenerateServerStreamResponse> =
  {
    encode(
      message: GenerateServerStreamResponse,
      writer: BinaryWriter = new BinaryWriter()
    ): BinaryWriter {
      if (message.id !== undefined) {
        writer.uint32(10).string(message.id);
      }
      for (const v of message.clips) {
        Clip.encode(v!, writer.uint32(18).fork()).join();
      }
      if (message.metadata !== undefined) {
        Metadata.encode(message.metadata, writer.uint32(26).fork()).join();
      }
      if (message.majorModelVersion !== undefined) {
        writer.uint32(34).string(message.majorModelVersion);
      }
      if (message.status !== undefined) {
        writer.uint32(42).string(message.status);
      }
      if (message.createdAt !== undefined) {
        writer.uint32(50).string(message.createdAt);
      }
      if (message.batchSize !== undefined) {
        writer.uint32(56).int32(message.batchSize);
      }
      if (message.message !== undefined) {
        writer.uint32(66).string(message.message);
      }
      return writer;
    },

    decode(
      input: BinaryReader | Uint8Array,
      length?: number
    ): GenerateServerStreamResponse {
      const reader =
        input instanceof BinaryReader ? input : new BinaryReader(input);
      let end = length === undefined ? reader.len : reader.pos + length;
      const message = createBaseGenerateServerStreamResponse();
      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.clips.push(Clip.decode(reader, reader.uint32()));
            continue;
          }
          case 3: {
            if (tag !== 26) {
              break;
            }

            message.metadata = Metadata.decode(reader, reader.uint32());
            continue;
          }
          case 4: {
            if (tag !== 34) {
              break;
            }

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

            message.status = reader.string();
            continue;
          }
          case 6: {
            if (tag !== 50) {
              break;
            }

            message.createdAt = reader.string();
            continue;
          }
          case 7: {
            if (tag !== 56) {
              break;
            }

            message.batchSize = reader.int32();
            continue;
          }
          case 8: {
            if (tag !== 66) {
              break;
            }

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

    fromJSON(object: any): GenerateServerStreamResponse {
      return {
        id: isSet(object.id) ? globalThis.String(object.id) : undefined,
        clips: globalThis.Array.isArray(object?.clips)
          ? object.clips.map((e: any) => Clip.fromJSON(e))
          : [],
        metadata: isSet(object.metadata)
          ? Metadata.fromJSON(object.metadata)
          : undefined,
        majorModelVersion: isSet(object.majorModelVersion)
          ? globalThis.String(object.majorModelVersion)
          : undefined,
        status: isSet(object.status)
          ? globalThis.String(object.status)
          : undefined,
        createdAt: isSet(object.createdAt)
          ? globalThis.String(object.createdAt)
          : undefined,
        batchSize: isSet(object.batchSize)
          ? globalThis.Number(object.batchSize)
          : undefined,
        message: isSet(object.message)
          ? globalThis.String(object.message)
          : undefined,
      };
    },

    toJSON(message: GenerateServerStreamResponse): unknown {
      const obj: any = {};
      if (message.id !== undefined) {
        obj.id = message.id;
      }
      if (message.clips?.length) {
        obj.clips = message.clips.map((e) => Clip.toJSON(e));
      }
      if (message.metadata !== undefined) {
        obj.metadata = Metadata.toJSON(message.metadata);
      }
      if (message.majorModelVersion !== undefined) {
        obj.majorModelVersion = message.majorModelVersion;
      }
      if (message.status !== undefined) {
        obj.status = message.status;
      }
      if (message.createdAt !== undefined) {
        obj.createdAt = message.createdAt;
      }
      if (message.batchSize !== undefined) {
        obj.batchSize = Math.round(message.batchSize);
      }
      if (message.message !== undefined) {
        obj.message = message.message;
      }
      return obj;
    },

    create<I extends Exact<DeepPartial<GenerateServerStreamResponse>, I>>(
      base?: I
    ): GenerateServerStreamResponse {
      return GenerateServerStreamResponse.fromPartial(base ?? ({} as any));
    },
    fromPartial<I extends Exact<DeepPartial<GenerateServerStreamResponse>, I>>(
      object: I
    ): GenerateServerStreamResponse {
      const message = createBaseGenerateServerStreamResponse();
      message.id = object.id ?? undefined;
      message.clips = object.clips?.map((e) => Clip.fromPartial(e)) || [];
      message.metadata =
        object.metadata !== undefined && object.metadata !== null
          ? Metadata.fromPartial(object.metadata)
          : undefined;
      message.majorModelVersion = object.majorModelVersion ?? undefined;
      message.status = object.status ?? undefined;
      message.createdAt = object.createdAt ?? undefined;
      message.batchSize = object.batchSize ?? undefined;
      message.message = object.message ?? undefined;
      return message;
    },
  };

function createBaseClip(): Clip {
  return {
    id: undefined,
    videoUrl: undefined,
    audioUrl: undefined,
    imageUrl: undefined,
    imageLargeUrl: undefined,
    isVideoPending: undefined,
    majorModelVersion: undefined,
    modelName: undefined,
    metadata: undefined,
    isLiked: undefined,
    userId: undefined,
    displayName: undefined,
    handle: undefined,
    isHandleUpdated: undefined,
    avatarImageUrl: undefined,
    isTrashed: undefined,
    reaction: undefined,
    createdAt: undefined,
    status: undefined,
    title: undefined,
    playCount: undefined,
    upvoteCount: undefined,
    isPublic: undefined,
  };
}

export const Clip: MessageFns<Clip> = {
  encode(
    message: Clip,
    writer: BinaryWriter = new BinaryWriter()
  ): BinaryWriter {
    if (message.id !== undefined) {
      writer.uint32(10).string(message.id);
    }
    if (message.videoUrl !== undefined) {
      writer.uint32(18).string(message.videoUrl);
    }
    if (message.audioUrl !== undefined) {
      writer.uint32(26).string(message.audioUrl);
    }
    if (message.imageUrl !== undefined) {
      writer.uint32(34).string(message.imageUrl);
    }
    if (message.imageLargeUrl !== undefined) {
      writer.uint32(42).string(message.imageLargeUrl);
    }
    if (message.isVideoPending !== undefined) {
      writer.uint32(48).bool(message.isVideoPending);
    }
    if (message.majorModelVersion !== undefined) {
      writer.uint32(58).string(message.majorModelVersion);
    }
    if (message.modelName !== undefined) {
      writer.uint32(66).string(message.modelName);
    }
    if (message.metadata !== undefined) {
      Metadata.encode(message.metadata, writer.uint32(74).fork()).join();
    }
    if (message.isLiked !== undefined) {
      writer.uint32(80).bool(message.isLiked);
    }
    if (message.userId !== undefined) {
      writer.uint32(90).string(message.userId);
    }
    if (message.displayName !== undefined) {
      writer.uint32(98).string(message.displayName);
    }
    if (message.handle !== undefined) {
      writer.uint32(106).string(message.handle);
    }
    if (message.isHandleUpdated !== undefined) {
      writer.uint32(112).bool(message.isHandleUpdated);
    }
    if (message.avatarImageUrl !== undefined) {
      writer.uint32(122).string(message.avatarImageUrl);
    }
    if (message.isTrashed !== undefined) {
      writer.uint32(128).bool(message.isTrashed);
    }
    if (message.reaction !== undefined) {
      Reaction.encode(message.reaction, writer.uint32(138).fork()).join();
    }
    if (message.createdAt !== undefined) {
      writer.uint32(146).string(message.createdAt);
    }
    if (message.status !== undefined) {
      writer.uint32(154).string(message.status);
    }
    if (message.title !== undefined) {
      writer.uint32(162).string(message.title);
    }
    if (message.playCount !== undefined) {
      writer.uint32(168).int32(message.playCount);
    }
    if (message.upvoteCount !== undefined) {
      writer.uint32(176).int32(message.upvoteCount);
    }
    if (message.isPublic !== undefined) {
      writer.uint32(184).bool(message.isPublic);
    }
    return writer;
  },

  decode(input: BinaryReader | Uint8Array, length?: number): Clip {
    const reader =
      input instanceof BinaryReader ? input : new BinaryReader(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseClip();
    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.videoUrl = reader.string();
          continue;
        }
        case 3: {
          if (tag !== 26) {
            break;
          }

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

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

          message.imageLargeUrl = reader.string();
          continue;
        }
        case 6: {
          if (tag !== 48) {
            break;
          }

          message.isVideoPending = reader.bool();
          continue;
        }
        case 7: {
          if (tag !== 58) {
            break;
          }

          message.majorModelVersion = reader.string();
          continue;
        }
        case 8: {
          if (tag !== 66) {
            break;
          }

          message.modelName = reader.string();
          continue;
        }
        case 9: {
          if (tag !== 74) {
            break;
          }

          message.metadata = Metadata.decode(reader, reader.uint32());
          continue;
        }
        case 10: {
          if (tag !== 80) {
            break;
          }

          message.isLiked = reader.bool();
          continue;
        }
        case 11: {
          if (tag !== 90) {
            break;
          }

          message.userId = reader.string();
          continue;
        }
        case 12: {
          if (tag !== 98) {
            break;
          }

          message.displayName = reader.string();
          continue;
        }
        case 13: {
          if (tag !== 106) {
            break;
          }

          message.handle = reader.string();
          continue;
        }
        case 14: {
          if (tag !== 112) {
            break;
          }

          message.isHandleUpdated = reader.bool();
          continue;
        }
        case 15: {
          if (tag !== 122) {
            break;
          }

          message.avatarImageUrl = reader.string();
          continue;
        }
        case 16: {
          if (tag !== 128) {
            break;
          }

          message.isTrashed = reader.bool();
          continue;
        }
        case 17: {
          if (tag !== 138) {
            break;
          }

          message.reaction = Reaction.decode(reader, reader.uint32());
          continue;
        }
        case 18: {
          if (tag !== 146) {
            break;
          }

          message.createdAt = reader.string();
          continue;
        }
        case 19: {
          if (tag !== 154) {
            break;
          }

          message.status = reader.string();
          continue;
        }
        case 20: {
          if (tag !== 162) {
            break;
          }

          message.title = reader.string();
          continue;
        }
        case 21: {
          if (tag !== 168) {
            break;
          }

          message.playCount = reader.int32();
          continue;
        }
        case 22: {
          if (tag !== 176) {
            break;
          }

          message.upvoteCount = reader.int32();
          continue;
        }
        case 23: {
          if (tag !== 184) {
            break;
          }

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

  fromJSON(object: any): Clip {
    return {
      id: isSet(object.id) ? globalThis.String(object.id) : undefined,
      videoUrl: isSet(object.videoUrl)
        ? globalThis.String(object.videoUrl)
        : undefined,
      audioUrl: isSet(object.audioUrl)
        ? globalThis.String(object.audioUrl)
        : undefined,
      imageUrl: isSet(object.imageUrl)
        ? globalThis.String(object.imageUrl)
        : undefined,
      imageLargeUrl: isSet(object.imageLargeUrl)
        ? globalThis.String(object.imageLargeUrl)
        : undefined,
      isVideoPending: isSet(object.isVideoPending)
        ? globalThis.Boolean(object.isVideoPending)
        : undefined,
      majorModelVersion: isSet(object.majorModelVersion)
        ? globalThis.String(object.majorModelVersion)
        : undefined,
      modelName: isSet(object.modelName)
        ? globalThis.String(object.modelName)
        : undefined,
      metadata: isSet(object.metadata)
        ? Metadata.fromJSON(object.metadata)
        : undefined,
      isLiked: isSet(object.isLiked)
        ? globalThis.Boolean(object.isLiked)
        : undefined,
      userId: isSet(object.userId)
        ? globalThis.String(object.userId)
        : undefined,
      displayName: isSet(object.displayName)
        ? globalThis.String(object.displayName)
        : undefined,
      handle: isSet(object.handle)
        ? globalThis.String(object.handle)
        : undefined,
      isHandleUpdated: isSet(object.isHandleUpdated)
        ? globalThis.Boolean(object.isHandleUpdated)
        : undefined,
      avatarImageUrl: isSet(object.avatarImageUrl)
        ? globalThis.String(object.avatarImageUrl)
        : undefined,
      isTrashed: isSet(object.isTrashed)
        ? globalThis.Boolean(object.isTrashed)
        : undefined,
      reaction: isSet(object.reaction)
        ? Reaction.fromJSON(object.reaction)
        : undefined,
      createdAt: isSet(object.createdAt)
        ? globalThis.String(object.createdAt)
        : undefined,
      status: isSet(object.status)
        ? globalThis.String(object.status)
        : undefined,
      title: isSet(object.title) ? globalThis.String(object.title) : undefined,
      playCount: isSet(object.playCount)
        ? globalThis.Number(object.playCount)
        : undefined,
      upvoteCount: isSet(object.upvoteCount)
        ? globalThis.Number(object.upvoteCount)
        : undefined,
      isPublic: isSet(object.isPublic)
        ? globalThis.Boolean(object.isPublic)
        : undefined,
    };
  },

  toJSON(message: Clip): unknown {
    const obj: any = {};
    if (message.id !== undefined) {
      obj.id = message.id;
    }
    if (message.videoUrl !== undefined) {
      obj.videoUrl = message.videoUrl;
    }
    if (message.audioUrl !== undefined) {
      obj.audioUrl = message.audioUrl;
    }
    if (message.imageUrl !== undefined) {
      obj.imageUrl = message.imageUrl;
    }
    if (message.imageLargeUrl !== undefined) {
      obj.imageLargeUrl = message.imageLargeUrl;
    }
    if (message.isVideoPending !== undefined) {
      obj.isVideoPending = message.isVideoPending;
    }
    if (message.majorModelVersion !== undefined) {
      obj.majorModelVersion = message.majorModelVersion;
    }
    if (message.modelName !== undefined) {
      obj.modelName = message.modelName;
    }
    if (message.metadata !== undefined) {
      obj.metadata = Metadata.toJSON(message.metadata);
    }
    if (message.isLiked !== undefined) {
      obj.isLiked = message.isLiked;
    }
    if (message.userId !== undefined) {
      obj.userId = message.userId;
    }
    if (message.displayName !== undefined) {
      obj.displayName = message.displayName;
    }
    if (message.handle !== undefined) {
      obj.handle = message.handle;
    }
    if (message.isHandleUpdated !== undefined) {
      obj.isHandleUpdated = message.isHandleUpdated;
    }
    if (message.avatarImageUrl !== undefined) {
      obj.avatarImageUrl = message.avatarImageUrl;
    }
    if (message.isTrashed !== undefined) {
      obj.isTrashed = message.isTrashed;
    }
    if (message.reaction !== undefined) {
      obj.reaction = Reaction.toJSON(message.reaction);
    }
    if (message.createdAt !== undefined) {
      obj.createdAt = message.createdAt;
    }
    if (message.status !== undefined) {
      obj.status = message.status;
    }
    if (message.title !== undefined) {
      obj.title = message.title;
    }
    if (message.playCount !== undefined) {
      obj.playCount = Math.round(message.playCount);
    }
    if (message.upvoteCount !== undefined) {
      obj.upvoteCount = Math.round(message.upvoteCount);
    }
    if (message.isPublic !== undefined) {
      obj.isPublic = message.isPublic;
    }
    return obj;
  },

  create<I extends Exact<DeepPartial<Clip>, I>>(base?: I): Clip {
    return Clip.fromPartial(base ?? ({} as any));
  },
  fromPartial<I extends Exact<DeepPartial<Clip>, I>>(object: I): Clip {
    const message = createBaseClip();
    message.id = object.id ?? undefined;
    message.videoUrl = object.videoUrl ?? undefined;
    message.audioUrl = object.audioUrl ?? undefined;
    message.imageUrl = object.imageUrl ?? undefined;
    message.imageLargeUrl = object.imageLargeUrl ?? undefined;
    message.isVideoPending = object.isVideoPending ?? undefined;
    message.majorModelVersion = object.majorModelVersion ?? undefined;
    message.modelName = object.modelName ?? undefined;
    message.metadata =
      object.metadata !== undefined && object.metadata !== null
        ? Metadata.fromPartial(object.metadata)
        : undefined;
    message.isLiked = object.isLiked ?? undefined;
    message.userId = object.userId ?? undefined;
    message.displayName = object.displayName ?? undefined;
    message.handle = object.handle ?? undefined;
    message.isHandleUpdated = object.isHandleUpdated ?? undefined;
    message.avatarImageUrl = object.avatarImageUrl ?? undefined;
    message.isTrashed = object.isTrashed ?? undefined;
    message.reaction =
      object.reaction !== undefined && object.reaction !== null
        ? Reaction.fromPartial(object.reaction)
        : undefined;
    message.createdAt = object.createdAt ?? undefined;
    message.status = object.status ?? undefined;
    message.title = object.title ?? undefined;
    message.playCount = object.playCount ?? undefined;
    message.upvoteCount = object.upvoteCount ?? undefined;
    message.isPublic = object.isPublic ?? undefined;
    return message;
  },
};

function createBaseMetadata(): Metadata {
  return {
    tags: undefined,
    negativeTags: undefined,
    prompt: undefined,
    gptDescriptionPrompt: undefined,
    history: [],
    concatHistory: [],
    stemFromId: undefined,
    type: undefined,
    duration: undefined,
    refundCredits: undefined,
    stream: undefined,
    infill: undefined,
    hasVocal: undefined,
    canPublishWithVocal: undefined,
    isAudioUploadTosAccepted: undefined,
    errorType: undefined,
    errorMessage: undefined,
    configurations: {},
    artistClipId: undefined,
    coverClipId: undefined,
    personaId: undefined,
    videoToSongVideoUploadId: undefined,
    videoToSongVideoUploadUrl: undefined,
    videoToSongVideoOutputUrl: undefined,
    imageToSongImageIds: [],
    imageToSongImageUrls: [],
    isImageToSong: undefined,
    isSunoShort: undefined,
    task: undefined,
    editSessionId: undefined,
  };
}

export const Metadata: MessageFns<Metadata> = {
  encode(
    message: Metadata,
    writer: BinaryWriter = new BinaryWriter()
  ): BinaryWriter {
    if (message.tags !== undefined) {
      writer.uint32(10).string(message.tags);
    }
    if (message.negativeTags !== undefined) {
      writer.uint32(18).string(message.negativeTags);
    }
    if (message.prompt !== undefined) {
      writer.uint32(26).string(message.prompt);
    }
    if (message.gptDescriptionPrompt !== undefined) {
      writer.uint32(34).string(message.gptDescriptionPrompt);
    }
    for (const v of message.history) {
      HistoryItem.encode(v!, writer.uint32(42).fork()).join();
    }
    for (const v of message.concatHistory) {
      HistoryItem.encode(v!, writer.uint32(50).fork()).join();
    }
    if (message.stemFromId !== undefined) {
      writer.uint32(58).string(message.stemFromId);
    }
    if (message.type !== undefined) {
      writer.uint32(66).string(message.type);
    }
    if (message.duration !== undefined) {
      writer.uint32(73).double(message.duration);
    }
    if (message.refundCredits !== undefined) {
      writer.uint32(80).bool(message.refundCredits);
    }
    if (message.stream !== undefined) {
      writer.uint32(88).bool(message.stream);
    }
    if (message.infill !== undefined) {
      writer.uint32(96).bool(message.infill);
    }
    if (message.hasVocal !== undefined) {
      writer.uint32(104).bool(message.hasVocal);
    }
    if (message.isAudioUploadTosAccepted !== undefined) {
      writer.uint32(112).bool(message.isAudioUploadTosAccepted);
    }
    if (message.errorType !== undefined) {
      writer.uint32(122).string(message.errorType);
    }
    if (message.errorMessage !== undefined) {
      writer.uint32(130).string(message.errorMessage);
    }
    Object.entries(message.configurations).forEach(([key, value]) => {
      Metadata_ConfigurationsEntry.encode(
        { key: key as any, value },
        writer.uint32(138).fork()
      ).join();
    });
    if (message.artistClipId !== undefined) {
      writer.uint32(146).string(message.artistClipId);
    }
    if (message.coverClipId !== undefined) {
      writer.uint32(154).string(message.coverClipId);
    }
    if (message.personaId !== undefined) {
      writer.uint32(162).string(message.personaId);
    }
    if (message.videoToSongVideoUploadId !== undefined) {
      writer.uint32(170).string(message.videoToSongVideoUploadId);
    }
    if (message.videoToSongVideoUploadUrl !== undefined) {
      writer.uint32(178).string(message.videoToSongVideoUploadUrl);
    }
    if (message.videoToSongVideoOutputUrl !== undefined) {
      writer.uint32(186).string(message.videoToSongVideoOutputUrl);
    }
    for (const v of message.imageToSongImageIds) {
      writer.uint32(194).string(v!);
    }
    for (const v of message.imageToSongImageUrls) {
      writer.uint32(202).string(v!);
    }
    if (message.isImageToSong !== undefined) {
      writer.uint32(208).bool(message.isImageToSong);
    }
    if (message.isSunoShort !== undefined) {
      writer.uint32(216).bool(message.isSunoShort);
    }
    if (message.task !== undefined) {
      writer.uint32(226).string(message.task);
    }
    if (message.editSessionId !== undefined) {
      writer.uint32(234).string(message.editSessionId);
    }
    return writer;
  },

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

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

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

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

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

          message.history.push(HistoryItem.decode(reader, reader.uint32()));
          continue;
        }
        case 6: {
          if (tag !== 50) {
            break;
          }

          message.concatHistory.push(
            HistoryItem.decode(reader, reader.uint32())
          );
          continue;
        }
        case 7: {
          if (tag !== 58) {
            break;
          }

          message.stemFromId = reader.string();
          continue;
        }
        case 8: {
          if (tag !== 66) {
            break;
          }

          message.type = reader.string();
          continue;
        }
        case 9: {
          if (tag !== 73) {
            break;
          }

          message.duration = reader.double();
          continue;
        }
        case 10: {
          if (tag !== 80) {
            break;
          }

          message.refundCredits = reader.bool();
          continue;
        }
        case 11: {
          if (tag !== 88) {
            break;
          }

          message.stream = reader.bool();
          continue;
        }
        case 12: {
          if (tag !== 96) {
            break;
          }

          message.infill = reader.bool();
          continue;
        }
        case 13: {
          if (tag !== 104) {
            break;
          }

          message.hasVocal = reader.bool();
          continue;
        }
        case 14: {
          if (tag !== 112) {
            break;
          }

          message.isAudioUploadTosAccepted = reader.bool();
          continue;
        }
        case 15: {
          if (tag !== 122) {
            break;
          }

          message.errorType = reader.string();
          continue;
        }
        case 16: {
          if (tag !== 130) {
            break;
          }

          message.errorMessage = reader.string();
          continue;
        }
        case 17: {
          if (tag !== 138) {
            break;
          }

          const entry17 = Metadata_ConfigurationsEntry.decode(
            reader,
            reader.uint32()
          );
          if (entry17.value !== undefined) {
            message.configurations[entry17.key] = entry17.value;
          }
          continue;
        }
        case 18: {
          if (tag !== 146) {
            break;
          }

          message.artistClipId = reader.string();
          continue;
        }
        case 19: {
          if (tag !== 154) {
            break;
          }

          message.coverClipId = reader.string();
          continue;
        }
        case 20: {
          if (tag !== 162) {
            break;
          }

          message.personaId = reader.string();
          continue;
        }
        case 21: {
          if (tag !== 170) {
            break;
          }

          message.videoToSongVideoUploadId = reader.string();
          continue;
        }
        case 22: {
          if (tag !== 178) {
            break;
          }

          message.videoToSongVideoUploadUrl = reader.string();
          continue;
        }
        case 23: {
          if (tag !== 186) {
            break;
          }

          message.videoToSongVideoOutputUrl = reader.string();
          continue;
        }
        case 24: {
          if (tag !== 194) {
            break;
          }

          message.imageToSongImageIds.push(reader.string());
          continue;
        }
        case 25: {
          if (tag !== 202) {
            break;
          }

          message.imageToSongImageUrls.push(reader.string());
          continue;
        }
        case 26: {
          if (tag !== 208) {
            break;
          }

          message.isImageToSong = reader.bool();
          continue;
        }
        case 27: {
          if (tag !== 216) {
            break;
          }

          message.isSunoShort = reader.bool();
          continue;
        }
        case 28: {
          if (tag !== 226) {
            break;
          }

          message.task = reader.string();
          continue;
        }
        case 29: {
          if (tag !== 234) {
            break;
          }

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

  fromJSON(object: any): Metadata {
    return {
      tags: isSet(object.tags) ? globalThis.String(object.tags) : undefined,
      negativeTags: isSet(object.negativeTags)
        ? globalThis.String(object.negativeTags)
        : undefined,
      prompt: isSet(object.prompt)
        ? globalThis.String(object.prompt)
        : undefined,
      gptDescriptionPrompt: isSet(object.gptDescriptionPrompt)
        ? globalThis.String(object.gptDescriptionPrompt)
        : undefined,
      history: globalThis.Array.isArray(object?.history)
        ? object.history.map((e: any) => HistoryItem.fromJSON(e))
        : [],
      concatHistory: globalThis.Array.isArray(object?.concatHistory)
        ? object.concatHistory.map((e: any) => HistoryItem.fromJSON(e))
        : [],
      stemFromId: isSet(object.stemFromId)
        ? globalThis.String(object.stemFromId)
        : undefined,
      type: isSet(object.type) ? globalThis.String(object.type) : undefined,
      duration: isSet(object.duration)
        ? globalThis.Number(object.duration)
        : undefined,
      refundCredits: isSet(object.refundCredits)
        ? globalThis.Boolean(object.refundCredits)
        : undefined,
      stream: isSet(object.stream)
        ? globalThis.Boolean(object.stream)
        : undefined,
      infill: isSet(object.infill)
        ? globalThis.Boolean(object.infill)
        : undefined,
      hasVocal: isSet(object.hasVocal)
        ? globalThis.Boolean(object.hasVocal)
        : undefined,
      isAudioUploadTosAccepted: isSet(object.isAudioUploadTosAccepted)
        ? globalThis.Boolean(object.isAudioUploadTosAccepted)
        : undefined,
      errorType: isSet(object.errorType)
        ? globalThis.String(object.errorType)
        : undefined,
      errorMessage: isSet(object.errorMessage)
        ? globalThis.String(object.errorMessage)
        : undefined,
      configurations: isObject(object.configurations)
        ? Object.entries(object.configurations).reduce<{
            [key: string]: number;
          }>((acc, [key, value]) => {
            acc[key] = Number(value);
            return acc;
          }, {})
        : {},
      artistClipId: isSet(object.artistClipId)
        ? globalThis.String(object.artistClipId)
        : undefined,
      coverClipId: isSet(object.coverClipId)
        ? globalThis.String(object.coverClipId)
        : undefined,
      personaId: isSet(object.personaId)
        ? globalThis.String(object.personaId)
        : undefined,
      videoToSongVideoUploadId: isSet(object.videoToSongVideoUploadId)
        ? globalThis.String(object.videoToSongVideoUploadId)
        : undefined,
      videoToSongVideoUploadUrl: isSet(object.videoToSongVideoUploadUrl)
        ? globalThis.String(object.videoToSongVideoUploadUrl)
        : undefined,
      videoToSongVideoOutputUrl: isSet(object.videoToSongVideoOutputUrl)
        ? globalThis.String(object.videoToSongVideoOutputUrl)
        : undefined,
      imageToSongImageIds: globalThis.Array.isArray(object?.imageToSongImageIds)
        ? object.imageToSongImageIds.map((e: any) => globalThis.String(e))
        : [],
      imageToSongImageUrls: globalThis.Array.isArray(
        object?.imageToSongImageUrls
      )
        ? object.imageToSongImageUrls.map((e: any) => globalThis.String(e))
        : [],
      isImageToSong: isSet(object.isImageToSong)
        ? globalThis.Boolean(object.isImageToSong)
        : undefined,
      isSunoShort: isSet(object.isSunoShort)
        ? globalThis.Boolean(object.isSunoShort)
        : undefined,
      task: isSet(object.task) ? globalThis.String(object.task) : undefined,
      editSessionId: isSet(object.editSessionId)
        ? globalThis.String(object.editSessionId)
        : undefined,
    };
  },

  toJSON(message: Metadata): unknown {
    const obj: any = {};
    if (message.tags !== undefined) {
      obj.tags = message.tags;
    }
    if (message.negativeTags !== undefined) {
      obj.negativeTags = message.negativeTags;
    }
    if (message.prompt !== undefined) {
      obj.prompt = message.prompt;
    }
    if (message.gptDescriptionPrompt !== undefined) {
      obj.gptDescriptionPrompt = message.gptDescriptionPrompt;
    }
    if (message.history?.length) {
      obj.history = message.history.map((e) => HistoryItem.toJSON(e));
    }
    if (message.concatHistory?.length) {
      obj.concatHistory = message.concatHistory.map((e) =>
        HistoryItem.toJSON(e)
      );
    }
    if (message.stemFromId !== undefined) {
      obj.stemFromId = message.stemFromId;
    }
    if (message.type !== undefined) {
      obj.type = message.type;
    }
    if (message.duration !== undefined) {
      obj.duration = message.duration;
    }
    if (message.refundCredits !== undefined) {
      obj.refundCredits = message.refundCredits;
    }
    if (message.stream !== undefined) {
      obj.stream = message.stream;
    }
    if (message.infill !== undefined) {
      obj.infill = message.infill;
    }
    if (message.hasVocal !== undefined) {
      obj.hasVocal = message.hasVocal;
    }
    if (message.isAudioUploadTosAccepted !== undefined) {
      obj.isAudioUploadTosAccepted = message.isAudioUploadTosAccepted;
    }
    if (message.errorType !== undefined) {
      obj.errorType = message.errorType;
    }
    if (message.errorMessage !== undefined) {
      obj.errorMessage = message.errorMessage;
    }
    if (message.configurations) {
      const entries = Object.entries(message.configurations);
      if (entries.length > 0) {
        obj.configurations = {};
        entries.forEach(([k, v]) => {
          obj.configurations[k] = Math.round(v);
        });
      }
    }
    if (message.artistClipId !== undefined) {
      obj.artistClipId = message.artistClipId;
    }
    if (message.coverClipId !== undefined) {
      obj.coverClipId = message.coverClipId;
    }
    if (message.personaId !== undefined) {
      obj.personaId = message.personaId;
    }
    if (message.videoToSongVideoUploadId !== undefined) {
      obj.videoToSongVideoUploadId = message.videoToSongVideoUploadId;
    }
    if (message.videoToSongVideoUploadUrl !== undefined) {
      obj.videoToSongVideoUploadUrl = message.videoToSongVideoUploadUrl;
    }
    if (message.videoToSongVideoOutputUrl !== undefined) {
      obj.videoToSongVideoOutputUrl = message.videoToSongVideoOutputUrl;
    }
    if (message.imageToSongImageIds?.length) {
      obj.imageToSongImageIds = message.imageToSongImageIds;
    }
    if (message.imageToSongImageUrls?.length) {
      obj.imageToSongImageUrls = message.imageToSongImageUrls;
    }
    if (message.isImageToSong !== undefined) {
      obj.isImageToSong = message.isImageToSong;
    }
    if (message.isSunoShort !== undefined) {
      obj.isSunoShort = message.isSunoShort;
    }
    if (message.task !== undefined) {
      obj.task = message.task;
    }
    if (message.editSessionId !== undefined) {
      obj.editSessionId = message.editSessionId;
    }
    return obj;
  },

  create<I extends Exact<DeepPartial<Metadata>, I>>(base?: I): Metadata {
    return Metadata.fromPartial(base ?? ({} as any));
  },
  fromPartial<I extends Exact<DeepPartial<Metadata>, I>>(object: I): Metadata {
    const message = createBaseMetadata();
    message.tags = object.tags ?? undefined;
    message.negativeTags = object.negativeTags ?? undefined;
    message.prompt = object.prompt ?? undefined;
    message.gptDescriptionPrompt = object.gptDescriptionPrompt ?? undefined;
    message.history =
      object.history?.map((e) => HistoryItem.fromPartial(e)) || [];
    message.concatHistory =
      object.concatHistory?.map((e) => HistoryItem.fromPartial(e)) || [];
    message.stemFromId = object.stemFromId ?? undefined;
    message.type = object.type ?? undefined;
    message.duration = object.duration ?? undefined;
    message.refundCredits = object.refundCredits ?? undefined;
    message.stream = object.stream ?? undefined;
    message.infill = object.infill ?? undefined;
    message.hasVocal = object.hasVocal ?? undefined;
    message.isAudioUploadTosAccepted =
      object.isAudioUploadTosAccepted ?? undefined;
    message.errorType = object.errorType ?? undefined;
    message.errorMessage = object.errorMessage ?? undefined;
    message.configurations = Object.entries(
      object.configurations ?? {}
    ).reduce<{ [key: string]: number }>((acc, [key, value]) => {
      if (value !== undefined) {
        acc[key] = globalThis.Number(value);
      }
      return acc;
    }, {});
    message.artistClipId = object.artistClipId ?? undefined;
    message.coverClipId = object.coverClipId ?? undefined;
    message.personaId = object.personaId ?? undefined;
    message.videoToSongVideoUploadId =
      object.videoToSongVideoUploadId ?? undefined;
    message.videoToSongVideoUploadUrl =
      object.videoToSongVideoUploadUrl ?? undefined;
    message.videoToSongVideoOutputUrl =
      object.videoToSongVideoOutputUrl ?? undefined;
    message.imageToSongImageIds =
      object.imageToSongImageIds?.map((e) => e) || [];
    message.imageToSongImageUrls =
      object.imageToSongImageUrls?.map((e) => e) || [];
    message.isImageToSong = object.isImageToSong ?? undefined;
    message.isSunoShort = object.isSunoShort ?? undefined;
    message.task = object.task ?? undefined;
    message.editSessionId = object.editSessionId ?? undefined;
    return message;
  },
};

function createBaseMetadata_ConfigurationsEntry(): Metadata_ConfigurationsEntry {
  return { key: '', value: 0 };
}

export const Metadata_ConfigurationsEntry: MessageFns<Metadata_ConfigurationsEntry> =
  {
    encode(
      message: Metadata_ConfigurationsEntry,
      writer: BinaryWriter = new BinaryWriter()
    ): BinaryWriter {
      if (message.key !== '') {
        writer.uint32(10).string(message.key);
      }
      if (message.value !== 0) {
        writer.uint32(16).int32(message.value);
      }
      return writer;
    },

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

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

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

    fromJSON(object: any): Metadata_ConfigurationsEntry {
      return {
        key: isSet(object.key) ? globalThis.String(object.key) : '',
        value: isSet(object.value) ? globalThis.Number(object.value) : 0,
      };
    },

    toJSON(message: Metadata_ConfigurationsEntry): unknown {
      const obj: any = {};
      if (message.key !== '') {
        obj.key = message.key;
      }
      if (message.value !== 0) {
        obj.value = Math.round(message.value);
      }
      return obj;
    },

    create<I extends Exact<DeepPartial<Metadata_ConfigurationsEntry>, I>>(
      base?: I
    ): Metadata_ConfigurationsEntry {
      return Metadata_ConfigurationsEntry.fromPartial(base ?? ({} as any));
    },
    fromPartial<I extends Exact<DeepPartial<Metadata_ConfigurationsEntry>, I>>(
      object: I
    ): Metadata_ConfigurationsEntry {
      const message = createBaseMetadata_ConfigurationsEntry();
      message.key = object.key ?? '';
      message.value = object.value ?? 0;
      return message;
    },
  };

function createBaseHistoryItem(): HistoryItem {
  return {
    id: undefined,
    continueAt: undefined,
    type: undefined,
    source: undefined,
    infill: undefined,
  };
}

export const HistoryItem: MessageFns<HistoryItem> = {
  encode(
    message: HistoryItem,
    writer: BinaryWriter = new BinaryWriter()
  ): BinaryWriter {
    if (message.id !== undefined) {
      writer.uint32(10).string(message.id);
    }
    if (message.continueAt !== undefined) {
      writer.uint32(17).double(message.continueAt);
    }
    if (message.type !== undefined) {
      writer.uint32(26).string(message.type);
    }
    if (message.source !== undefined) {
      writer.uint32(34).string(message.source);
    }
    if (message.infill !== undefined) {
      writer.uint32(40).bool(message.infill);
    }
    return writer;
  },

  decode(input: BinaryReader | Uint8Array, length?: number): HistoryItem {
    const reader =
      input instanceof BinaryReader ? input : new BinaryReader(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseHistoryItem();
    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 !== 17) {
            break;
          }

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

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

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

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

  fromJSON(object: any): HistoryItem {
    return {
      id: isSet(object.id) ? globalThis.String(object.id) : undefined,
      continueAt: isSet(object.continueAt)
        ? globalThis.Number(object.continueAt)
        : undefined,
      type: isSet(object.type) ? globalThis.String(object.type) : undefined,
      source: isSet(object.source)
        ? globalThis.String(object.source)
        : undefined,
      infill: isSet(object.infill)
        ? globalThis.Boolean(object.infill)
        : undefined,
    };
  },

  toJSON(message: HistoryItem): unknown {
    const obj: any = {};
    if (message.id !== undefined) {
      obj.id = message.id;
    }
    if (message.continueAt !== undefined) {
      obj.continueAt = message.continueAt;
    }
    if (message.type !== undefined) {
      obj.type = message.type;
    }
    if (message.source !== undefined) {
      obj.source = message.source;
    }
    if (message.infill !== undefined) {
      obj.infill = message.infill;
    }
    return obj;
  },

  create<I extends Exact<DeepPartial<HistoryItem>, I>>(base?: I): HistoryItem {
    return HistoryItem.fromPartial(base ?? ({} as any));
  },
  fromPartial<I extends Exact<DeepPartial<HistoryItem>, I>>(
    object: I
  ): HistoryItem {
    const message = createBaseHistoryItem();
    message.id = object.id ?? undefined;
    message.continueAt = object.continueAt ?? undefined;
    message.type = object.type ?? undefined;
    message.source = object.source ?? undefined;
    message.infill = object.infill ?? undefined;
    return message;
  },
};

function createBaseReaction(): Reaction {
  return {
    playCount: undefined,
    skipCount: undefined,
    flagged: undefined,
    flaggedReason: undefined,
    feedbackReason: undefined,
    reactionType: undefined,
    clip: undefined,
    updatedAt: undefined,
  };
}

export const Reaction: MessageFns<Reaction> = {
  encode(
    message: Reaction,
    writer: BinaryWriter = new BinaryWriter()
  ): BinaryWriter {
    if (message.playCount !== undefined) {
      writer.uint32(8).int32(message.playCount);
    }
    if (message.skipCount !== undefined) {
      writer.uint32(16).int32(message.skipCount);
    }
    if (message.flagged !== undefined) {
      writer.uint32(24).bool(message.flagged);
    }
    if (message.flaggedReason !== undefined) {
      writer.uint32(34).string(message.flaggedReason);
    }
    if (message.feedbackReason !== undefined) {
      writer.uint32(42).string(message.feedbackReason);
    }
    if (message.reactionType !== undefined) {
      writer.uint32(50).string(message.reactionType);
    }
    if (message.clip !== undefined) {
      writer.uint32(58).string(message.clip);
    }
    if (message.updatedAt !== undefined) {
      writer.uint32(66).string(message.updatedAt);
    }
    return writer;
  },

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

          message.playCount = reader.int32();
          continue;
        }
        case 2: {
          if (tag !== 16) {
            break;
          }

          message.skipCount = reader.int32();
          continue;
        }
        case 3: {
          if (tag !== 24) {
            break;
          }

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

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

          message.feedbackReason = reader.string();
          continue;
        }
        case 6: {
          if (tag !== 50) {
            break;
          }

          message.reactionType = reader.string();
          continue;
        }
        case 7: {
          if (tag !== 58) {
            break;
          }

          message.clip = reader.string();
          continue;
        }
        case 8: {
          if (tag !== 66) {
            break;
          }

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

  fromJSON(object: any): Reaction {
    return {
      playCount: isSet(object.playCount)
        ? globalThis.Number(object.playCount)
        : undefined,
      skipCount: isSet(object.skipCount)
        ? globalThis.Number(object.skipCount)
        : undefined,
      flagged: isSet(object.flagged)
        ? globalThis.Boolean(object.flagged)
        : undefined,
      flaggedReason: isSet(object.flaggedReason)
        ? globalThis.String(object.flaggedReason)
        : undefined,
      feedbackReason: isSet(object.feedbackReason)
        ? globalThis.String(object.feedbackReason)
        : undefined,
      reactionType: isSet(object.reactionType)
        ? globalThis.String(object.reactionType)
        : undefined,
      clip: isSet(object.clip) ? globalThis.String(object.clip) : undefined,
      updatedAt: isSet(object.updatedAt)
        ? globalThis.String(object.updatedAt)
        : undefined,
    };
  },

  toJSON(message: Reaction): unknown {
    const obj: any = {};
    if (message.playCount !== undefined) {
      obj.playCount = Math.round(message.playCount);
    }
    if (message.skipCount !== undefined) {
      obj.skipCount = Math.round(message.skipCount);
    }
    if (message.flagged !== undefined) {
      obj.flagged = message.flagged;
    }
    if (message.flaggedReason !== undefined) {
      obj.flaggedReason = message.flaggedReason;
    }
    if (message.feedbackReason !== undefined) {
      obj.feedbackReason = message.feedbackReason;
    }
    if (message.reactionType !== undefined) {
      obj.reactionType = message.reactionType;
    }
    if (message.clip !== undefined) {
      obj.clip = message.clip;
    }
    if (message.updatedAt !== undefined) {
      obj.updatedAt = message.updatedAt;
    }
    return obj;
  },

  create<I extends Exact<DeepPartial<Reaction>, I>>(base?: I): Reaction {
    return Reaction.fromPartial(base ?? ({} as any));
  },
  fromPartial<I extends Exact<DeepPartial<Reaction>, I>>(object: I): Reaction {
    const message = createBaseReaction();
    message.playCount = object.playCount ?? undefined;
    message.skipCount = object.skipCount ?? undefined;
    message.flagged = object.flagged ?? undefined;
    message.flaggedReason = object.flaggedReason ?? undefined;
    message.feedbackReason = object.feedbackReason ?? undefined;
    message.reactionType = object.reactionType ?? undefined;
    message.clip = object.clip ?? undefined;
    message.updatedAt = object.updatedAt ?? undefined;
    return message;
  },
};

export type StudioApiGrpcServiceService = typeof StudioApiGrpcServiceService;
export const StudioApiGrpcServiceService = {
  /** Client streaming RPC */
  generateClientStream: {
    path: '/studio_api_grpc.StudioApiGrpcService/GenerateClientStream',
    requestStream: true,
    responseStream: false,
    requestSerialize: (value: GenerateRequest) =>
      Buffer.from(GenerateRequest.encode(value).finish()),
    requestDeserialize: (value: Buffer) => GenerateRequest.decode(value),
    responseSerialize: (value: GenerateResponse) =>
      Buffer.from(GenerateResponse.encode(value).finish()),
    responseDeserialize: (value: Buffer) => GenerateResponse.decode(value),
  },
  /** Server streaming RPC */
  generateClipServerStream: {
    path: '/studio_api_grpc.StudioApiGrpcService/GenerateClipServerStream',
    requestStream: false,
    responseStream: true,
    requestSerialize: (value: GenerateServerStreamRequest) =>
      Buffer.from(GenerateServerStreamRequest.encode(value).finish()),
    requestDeserialize: (value: Buffer) =>
      GenerateServerStreamRequest.decode(value),
    responseSerialize: (value: GenerateServerStreamResponse) =>
      Buffer.from(GenerateServerStreamResponse.encode(value).finish()),
    responseDeserialize: (value: Buffer) =>
      GenerateServerStreamResponse.decode(value),
  },
  /** Bidirectional streaming RPC */
  generateBidirectionalStream: {
    path: '/studio_api_grpc.StudioApiGrpcService/GenerateBidirectionalStream',
    requestStream: true,
    responseStream: true,
    requestSerialize: (value: GenerateRequest) =>
      Buffer.from(GenerateRequest.encode(value).finish()),
    requestDeserialize: (value: Buffer) => GenerateRequest.decode(value),
    responseSerialize: (value: GenerateResponse) =>
      Buffer.from(GenerateResponse.encode(value).finish()),
    responseDeserialize: (value: Buffer) => GenerateResponse.decode(value),
  },
  /** Normal non-streaming RPC */
  generate: {
    path: '/studio_api_grpc.StudioApiGrpcService/Generate',
    requestStream: false,
    responseStream: false,
    requestSerialize: (value: GenerateRequest) =>
      Buffer.from(GenerateRequest.encode(value).finish()),
    requestDeserialize: (value: Buffer) => GenerateRequest.decode(value),
    responseSerialize: (value: GenerateResponse) =>
      Buffer.from(GenerateResponse.encode(value).finish()),
    responseDeserialize: (value: Buffer) => GenerateResponse.decode(value),
  },
  /** Health check RPC */
  checkHealth: {
    path: '/studio_api_grpc.StudioApiGrpcService/CheckHealth',
    requestStream: false,
    responseStream: false,
    requestSerialize: (value: HealthCheckRequest) =>
      Buffer.from(HealthCheckRequest.encode(value).finish()),
    requestDeserialize: (value: Buffer) => HealthCheckRequest.decode(value),
    responseSerialize: (value: HealthCheckResponse) =>
      Buffer.from(HealthCheckResponse.encode(value).finish()),
    responseDeserialize: (value: Buffer) => HealthCheckResponse.decode(value),
  },
} as const;

export interface StudioApiGrpcServiceServer
  extends UntypedServiceImplementation {
  /** Client streaming RPC */
  generateClientStream: handleClientStreamingCall<
    GenerateRequest,
    GenerateResponse
  >;
  /** Server streaming RPC */
  generateClipServerStream: handleServerStreamingCall<
    GenerateServerStreamRequest,
    GenerateServerStreamResponse
  >;
  /** Bidirectional streaming RPC */
  generateBidirectionalStream: handleBidiStreamingCall<
    GenerateRequest,
    GenerateResponse
  >;
  /** Normal non-streaming RPC */
  generate: handleUnaryCall<GenerateRequest, GenerateResponse>;
  /** Health check RPC */
  checkHealth: handleUnaryCall<HealthCheckRequest, HealthCheckResponse>;
}

export interface StudioApiGrpcServiceClient extends Client {
  /** Client streaming RPC */
  generateClientStream(
    callback: (error: ServiceError | null, response: GenerateResponse) => void
  ): ClientWritableStream<GenerateRequest>;
  generateClientStream(
    metadata: Metadata1,
    callback: (error: ServiceError | null, response: GenerateResponse) => void
  ): ClientWritableStream<GenerateRequest>;
  generateClientStream(
    options: Partial<CallOptions>,
    callback: (error: ServiceError | null, response: GenerateResponse) => void
  ): ClientWritableStream<GenerateRequest>;
  generateClientStream(
    metadata: Metadata1,
    options: Partial<CallOptions>,
    callback: (error: ServiceError | null, response: GenerateResponse) => void
  ): ClientWritableStream<GenerateRequest>;
  /** Server streaming RPC */
  generateClipServerStream(
    request: GenerateServerStreamRequest,
    options?: Partial<CallOptions>
  ): ClientReadableStream<GenerateServerStreamResponse>;
  generateClipServerStream(
    request: GenerateServerStreamRequest,
    metadata?: Metadata1,
    options?: Partial<CallOptions>
  ): ClientReadableStream<GenerateServerStreamResponse>;
  /** Bidirectional streaming RPC */
  generateBidirectionalStream(): ClientDuplexStream<
    GenerateRequest,
    GenerateResponse
  >;
  generateBidirectionalStream(
    options: Partial<CallOptions>
  ): ClientDuplexStream<GenerateRequest, GenerateResponse>;
  generateBidirectionalStream(
    metadata: Metadata1,
    options?: Partial<CallOptions>
  ): ClientDuplexStream<GenerateRequest, GenerateResponse>;
  /** Normal non-streaming RPC */
  generate(
    request: GenerateRequest,
    callback: (error: ServiceError | null, response: GenerateResponse) => void
  ): ClientUnaryCall;
  generate(
    request: GenerateRequest,
    metadata: Metadata1,
    callback: (error: ServiceError | null, response: GenerateResponse) => void
  ): ClientUnaryCall;
  generate(
    request: GenerateRequest,
    metadata: Metadata1,
    options: Partial<CallOptions>,
    callback: (error: ServiceError | null, response: GenerateResponse) => void
  ): ClientUnaryCall;
  /** Health check RPC */
  checkHealth(
    request: HealthCheckRequest,
    callback: (
      error: ServiceError | null,
      response: HealthCheckResponse
    ) => void
  ): ClientUnaryCall;
  checkHealth(
    request: HealthCheckRequest,
    metadata: Metadata1,
    callback: (
      error: ServiceError | null,
      response: HealthCheckResponse
    ) => void
  ): ClientUnaryCall;
  checkHealth(
    request: HealthCheckRequest,
    metadata: Metadata1,
    options: Partial<CallOptions>,
    callback: (
      error: ServiceError | null,
      response: HealthCheckResponse
    ) => void
  ): ClientUnaryCall;
}

export const StudioApiGrpcServiceClient = makeGenericClientConstructor(
  StudioApiGrpcServiceService,
  'studio_api_grpc.StudioApiGrpcService'
) as unknown as {
  new (
    address: string,
    credentials: ChannelCredentials,
    options?: Partial<ClientOptions>
  ): StudioApiGrpcServiceClient;
  service: typeof StudioApiGrpcServiceService;
  serviceName: string;
};

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

export type DeepPartial<T> = T extends Builtin
  ? T
  : 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;
export 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 isObject(value: any): boolean {
  return typeof value === 'object' && value !== null;
}

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

export 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;
}
