// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
//   protoc-gen-ts_proto  v2.6.1
//   protoc               unknown
// source: api/v1/workspace_service.proto

/* eslint-disable */
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
import { FieldMask } from "../../google/protobuf/field_mask";

export const protobufPackage = "memos.api.v1";

/** Workspace profile message containing basic workspace information. */
export interface WorkspaceProfile {
  /**
   * The name of instance owner.
   * Format: users/{user}
   */
  owner: string;
  /** Version is the current version of instance. */
  version: string;
  /** Mode is the instance mode (e.g. "prod", "dev" or "demo"). */
  mode: string;
  /** Instance URL is the URL of the instance. */
  instanceUrl: string;
}

/** Request for workspace profile. */
export interface GetWorkspaceProfileRequest {
}

/** A workspace setting resource. */
export interface WorkspaceSetting {
  /**
   * The name of the workspace setting.
   * Format: workspace/settings/{setting}
   */
  name: string;
  generalSetting?: WorkspaceSetting_GeneralSetting | undefined;
  storageSetting?: WorkspaceSetting_StorageSetting | undefined;
  memoRelatedSetting?: WorkspaceSetting_MemoRelatedSetting | undefined;
}

/** Enumeration of workspace setting keys. */
export enum WorkspaceSetting_Key {
  KEY_UNSPECIFIED = "KEY_UNSPECIFIED",
  /** GENERAL - GENERAL is the key for general settings. */
  GENERAL = "GENERAL",
  /** STORAGE - STORAGE is the key for storage settings. */
  STORAGE = "STORAGE",
  /** MEMO_RELATED - MEMO_RELATED is the key for memo related settings. */
  MEMO_RELATED = "MEMO_RELATED",
  UNRECOGNIZED = "UNRECOGNIZED",
}

export function workspaceSetting_KeyFromJSON(object: any): WorkspaceSetting_Key {
  switch (object) {
    case 0:
    case "KEY_UNSPECIFIED":
      return WorkspaceSetting_Key.KEY_UNSPECIFIED;
    case 1:
    case "GENERAL":
      return WorkspaceSetting_Key.GENERAL;
    case 2:
    case "STORAGE":
      return WorkspaceSetting_Key.STORAGE;
    case 3:
    case "MEMO_RELATED":
      return WorkspaceSetting_Key.MEMO_RELATED;
    case -1:
    case "UNRECOGNIZED":
    default:
      return WorkspaceSetting_Key.UNRECOGNIZED;
  }
}

export function workspaceSetting_KeyToNumber(object: WorkspaceSetting_Key): number {
  switch (object) {
    case WorkspaceSetting_Key.KEY_UNSPECIFIED:
      return 0;
    case WorkspaceSetting_Key.GENERAL:
      return 1;
    case WorkspaceSetting_Key.STORAGE:
      return 2;
    case WorkspaceSetting_Key.MEMO_RELATED:
      return 3;
    case WorkspaceSetting_Key.UNRECOGNIZED:
    default:
      return -1;
  }
}

/** General workspace settings configuration. */
export interface WorkspaceSetting_GeneralSetting {
  /**
   * theme is the name of the selected theme.
   * This references a CSS file in the web/public/themes/ directory.
   */
  theme: string;
  /** disallow_user_registration disallows user registration. */
  disallowUserRegistration: boolean;
  /** disallow_password_auth disallows password authentication. */
  disallowPasswordAuth: boolean;
  /** additional_script is the additional script. */
  additionalScript: string;
  /** additional_style is the additional style. */
  additionalStyle: string;
  /** custom_profile is the custom profile. */
  customProfile?:
    | WorkspaceSetting_GeneralSetting_CustomProfile
    | undefined;
  /**
   * week_start_day_offset is the week start day offset from Sunday.
   * 0: Sunday, 1: Monday, 2: Tuesday, 3: Wednesday, 4: Thursday, 5: Friday, 6: Saturday
   * Default is Sunday.
   */
  weekStartDayOffset: number;
  /** disallow_change_username disallows changing username. */
  disallowChangeUsername: boolean;
  /** disallow_change_nickname disallows changing nickname. */
  disallowChangeNickname: boolean;
}

/** Custom profile configuration for workspace branding. */
export interface WorkspaceSetting_GeneralSetting_CustomProfile {
  title: string;
  description: string;
  logoUrl: string;
  locale: string;
}

/** Storage configuration settings for workspace attachments. */
export interface WorkspaceSetting_StorageSetting {
  /** storage_type is the storage type. */
  storageType: WorkspaceSetting_StorageSetting_StorageType;
  /**
   * The template of file path.
   * e.g. assets/{timestamp}_{filename}
   */
  filepathTemplate: string;
  /** The max upload size in megabytes. */
  uploadSizeLimitMb: number;
  /** The S3 config. */
  s3Config?: WorkspaceSetting_StorageSetting_S3Config | undefined;
}

/** Storage type enumeration for different storage backends. */
export enum WorkspaceSetting_StorageSetting_StorageType {
  STORAGE_TYPE_UNSPECIFIED = "STORAGE_TYPE_UNSPECIFIED",
  /** DATABASE - DATABASE is the database storage type. */
  DATABASE = "DATABASE",
  /** LOCAL - LOCAL is the local storage type. */
  LOCAL = "LOCAL",
  /** S3 - S3 is the S3 storage type. */
  S3 = "S3",
  UNRECOGNIZED = "UNRECOGNIZED",
}

export function workspaceSetting_StorageSetting_StorageTypeFromJSON(
  object: any,
): WorkspaceSetting_StorageSetting_StorageType {
  switch (object) {
    case 0:
    case "STORAGE_TYPE_UNSPECIFIED":
      return WorkspaceSetting_StorageSetting_StorageType.STORAGE_TYPE_UNSPECIFIED;
    case 1:
    case "DATABASE":
      return WorkspaceSetting_StorageSetting_StorageType.DATABASE;
    case 2:
    case "LOCAL":
      return WorkspaceSetting_StorageSetting_StorageType.LOCAL;
    case 3:
    case "S3":
      return WorkspaceSetting_StorageSetting_StorageType.S3;
    case -1:
    case "UNRECOGNIZED":
    default:
      return WorkspaceSetting_StorageSetting_StorageType.UNRECOGNIZED;
  }
}

export function workspaceSetting_StorageSetting_StorageTypeToNumber(
  object: WorkspaceSetting_StorageSetting_StorageType,
): number {
  switch (object) {
    case WorkspaceSetting_StorageSetting_StorageType.STORAGE_TYPE_UNSPECIFIED:
      return 0;
    case WorkspaceSetting_StorageSetting_StorageType.DATABASE:
      return 1;
    case WorkspaceSetting_StorageSetting_StorageType.LOCAL:
      return 2;
    case WorkspaceSetting_StorageSetting_StorageType.S3:
      return 3;
    case WorkspaceSetting_StorageSetting_StorageType.UNRECOGNIZED:
    default:
      return -1;
  }
}

/**
 * S3 configuration for cloud storage backend.
 * Reference: https://developers.cloudflare.com/r2/examples/aws/aws-sdk-go/
 */
export interface WorkspaceSetting_StorageSetting_S3Config {
  accessKeyId: string;
  accessKeySecret: string;
  endpoint: string;
  region: string;
  bucket: string;
  usePathStyle: boolean;
}

/** Memo-related workspace settings and policies. */
export interface WorkspaceSetting_MemoRelatedSetting {
  /** disallow_public_visibility disallows set memo as public visibility. */
  disallowPublicVisibility: boolean;
  /** display_with_update_time orders and displays memo with update time. */
  displayWithUpdateTime: boolean;
  /** content_length_limit is the limit of content length. Unit is byte. */
  contentLengthLimit: number;
  /** enable_double_click_edit enables editing on double click. */
  enableDoubleClickEdit: boolean;
  /** enable_link_preview enables links preview. */
  enableLinkPreview: boolean;
  /** reactions is the list of reactions. */
  reactions: string[];
  /** disable_markdown_shortcuts disallow the registration of markdown shortcuts. */
  disableMarkdownShortcuts: boolean;
  /** enable_blur_nsfw_content enables blurring of content marked as not safe for work (NSFW). */
  enableBlurNsfwContent: boolean;
  /** nsfw_tags is the list of tags that mark content as NSFW for blurring. */
  nsfwTags: string[];
}

/** Request message for GetWorkspaceSetting method. */
export interface GetWorkspaceSettingRequest {
  /**
   * The resource name of the workspace setting.
   * Format: workspace/settings/{setting}
   */
  name: string;
}

/** Request message for UpdateWorkspaceSetting method. */
export interface UpdateWorkspaceSettingRequest {
  /** The workspace setting resource which replaces the resource on the server. */
  setting?:
    | WorkspaceSetting
    | undefined;
  /** The list of fields to update. */
  updateMask?: string[] | undefined;
}

function createBaseWorkspaceProfile(): WorkspaceProfile {
  return { owner: "", version: "", mode: "", instanceUrl: "" };
}

export const WorkspaceProfile: MessageFns<WorkspaceProfile> = {
  encode(message: WorkspaceProfile, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
    if (message.owner !== "") {
      writer.uint32(10).string(message.owner);
    }
    if (message.version !== "") {
      writer.uint32(18).string(message.version);
    }
    if (message.mode !== "") {
      writer.uint32(26).string(message.mode);
    }
    if (message.instanceUrl !== "") {
      writer.uint32(50).string(message.instanceUrl);
    }
    return writer;
  },

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

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

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

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

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

  create(base?: DeepPartial<WorkspaceProfile>): WorkspaceProfile {
    return WorkspaceProfile.fromPartial(base ?? {});
  },
  fromPartial(object: DeepPartial<WorkspaceProfile>): WorkspaceProfile {
    const message = createBaseWorkspaceProfile();
    message.owner = object.owner ?? "";
    message.version = object.version ?? "";
    message.mode = object.mode ?? "";
    message.instanceUrl = object.instanceUrl ?? "";
    return message;
  },
};

function createBaseGetWorkspaceProfileRequest(): GetWorkspaceProfileRequest {
  return {};
}

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

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

  create(base?: DeepPartial<GetWorkspaceProfileRequest>): GetWorkspaceProfileRequest {
    return GetWorkspaceProfileRequest.fromPartial(base ?? {});
  },
  fromPartial(_: DeepPartial<GetWorkspaceProfileRequest>): GetWorkspaceProfileRequest {
    const message = createBaseGetWorkspaceProfileRequest();
    return message;
  },
};

function createBaseWorkspaceSetting(): WorkspaceSetting {
  return { name: "", generalSetting: undefined, storageSetting: undefined, memoRelatedSetting: undefined };
}

export const WorkspaceSetting: MessageFns<WorkspaceSetting> = {
  encode(message: WorkspaceSetting, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
    if (message.name !== "") {
      writer.uint32(10).string(message.name);
    }
    if (message.generalSetting !== undefined) {
      WorkspaceSetting_GeneralSetting.encode(message.generalSetting, writer.uint32(18).fork()).join();
    }
    if (message.storageSetting !== undefined) {
      WorkspaceSetting_StorageSetting.encode(message.storageSetting, writer.uint32(26).fork()).join();
    }
    if (message.memoRelatedSetting !== undefined) {
      WorkspaceSetting_MemoRelatedSetting.encode(message.memoRelatedSetting, writer.uint32(34).fork()).join();
    }
    return writer;
  },

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

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

          message.generalSetting = WorkspaceSetting_GeneralSetting.decode(reader, reader.uint32());
          continue;
        }
        case 3: {
          if (tag !== 26) {
            break;
          }

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

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

  create(base?: DeepPartial<WorkspaceSetting>): WorkspaceSetting {
    return WorkspaceSetting.fromPartial(base ?? {});
  },
  fromPartial(object: DeepPartial<WorkspaceSetting>): WorkspaceSetting {
    const message = createBaseWorkspaceSetting();
    message.name = object.name ?? "";
    message.generalSetting = (object.generalSetting !== undefined && object.generalSetting !== null)
      ? WorkspaceSetting_GeneralSetting.fromPartial(object.generalSetting)
      : undefined;
    message.storageSetting = (object.storageSetting !== undefined && object.storageSetting !== null)
      ? WorkspaceSetting_StorageSetting.fromPartial(object.storageSetting)
      : undefined;
    message.memoRelatedSetting = (object.memoRelatedSetting !== undefined && object.memoRelatedSetting !== null)
      ? WorkspaceSetting_MemoRelatedSetting.fromPartial(object.memoRelatedSetting)
      : undefined;
    return message;
  },
};

function createBaseWorkspaceSetting_GeneralSetting(): WorkspaceSetting_GeneralSetting {
  return {
    theme: "",
    disallowUserRegistration: false,
    disallowPasswordAuth: false,
    additionalScript: "",
    additionalStyle: "",
    customProfile: undefined,
    weekStartDayOffset: 0,
    disallowChangeUsername: false,
    disallowChangeNickname: false,
  };
}

export const WorkspaceSetting_GeneralSetting: MessageFns<WorkspaceSetting_GeneralSetting> = {
  encode(message: WorkspaceSetting_GeneralSetting, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
    if (message.theme !== "") {
      writer.uint32(10).string(message.theme);
    }
    if (message.disallowUserRegistration !== false) {
      writer.uint32(16).bool(message.disallowUserRegistration);
    }
    if (message.disallowPasswordAuth !== false) {
      writer.uint32(24).bool(message.disallowPasswordAuth);
    }
    if (message.additionalScript !== "") {
      writer.uint32(34).string(message.additionalScript);
    }
    if (message.additionalStyle !== "") {
      writer.uint32(42).string(message.additionalStyle);
    }
    if (message.customProfile !== undefined) {
      WorkspaceSetting_GeneralSetting_CustomProfile.encode(message.customProfile, writer.uint32(50).fork()).join();
    }
    if (message.weekStartDayOffset !== 0) {
      writer.uint32(56).int32(message.weekStartDayOffset);
    }
    if (message.disallowChangeUsername !== false) {
      writer.uint32(64).bool(message.disallowChangeUsername);
    }
    if (message.disallowChangeNickname !== false) {
      writer.uint32(72).bool(message.disallowChangeNickname);
    }
    return writer;
  },

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

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

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

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

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

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

          message.customProfile = WorkspaceSetting_GeneralSetting_CustomProfile.decode(reader, reader.uint32());
          continue;
        }
        case 7: {
          if (tag !== 56) {
            break;
          }

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

          message.disallowChangeUsername = reader.bool();
          continue;
        }
        case 9: {
          if (tag !== 72) {
            break;
          }

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

  create(base?: DeepPartial<WorkspaceSetting_GeneralSetting>): WorkspaceSetting_GeneralSetting {
    return WorkspaceSetting_GeneralSetting.fromPartial(base ?? {});
  },
  fromPartial(object: DeepPartial<WorkspaceSetting_GeneralSetting>): WorkspaceSetting_GeneralSetting {
    const message = createBaseWorkspaceSetting_GeneralSetting();
    message.theme = object.theme ?? "";
    message.disallowUserRegistration = object.disallowUserRegistration ?? false;
    message.disallowPasswordAuth = object.disallowPasswordAuth ?? false;
    message.additionalScript = object.additionalScript ?? "";
    message.additionalStyle = object.additionalStyle ?? "";
    message.customProfile = (object.customProfile !== undefined && object.customProfile !== null)
      ? WorkspaceSetting_GeneralSetting_CustomProfile.fromPartial(object.customProfile)
      : undefined;
    message.weekStartDayOffset = object.weekStartDayOffset ?? 0;
    message.disallowChangeUsername = object.disallowChangeUsername ?? false;
    message.disallowChangeNickname = object.disallowChangeNickname ?? false;
    return message;
  },
};

function createBaseWorkspaceSetting_GeneralSetting_CustomProfile(): WorkspaceSetting_GeneralSetting_CustomProfile {
  return { title: "", description: "", logoUrl: "", locale: "" };
}

export const WorkspaceSetting_GeneralSetting_CustomProfile: MessageFns<WorkspaceSetting_GeneralSetting_CustomProfile> =
  {
    encode(
      message: WorkspaceSetting_GeneralSetting_CustomProfile,
      writer: BinaryWriter = new BinaryWriter(),
    ): BinaryWriter {
      if (message.title !== "") {
        writer.uint32(10).string(message.title);
      }
      if (message.description !== "") {
        writer.uint32(18).string(message.description);
      }
      if (message.logoUrl !== "") {
        writer.uint32(26).string(message.logoUrl);
      }
      if (message.locale !== "") {
        writer.uint32(34).string(message.locale);
      }
      return writer;
    },

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

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

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

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

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

    create(
      base?: DeepPartial<WorkspaceSetting_GeneralSetting_CustomProfile>,
    ): WorkspaceSetting_GeneralSetting_CustomProfile {
      return WorkspaceSetting_GeneralSetting_CustomProfile.fromPartial(base ?? {});
    },
    fromPartial(
      object: DeepPartial<WorkspaceSetting_GeneralSetting_CustomProfile>,
    ): WorkspaceSetting_GeneralSetting_CustomProfile {
      const message = createBaseWorkspaceSetting_GeneralSetting_CustomProfile();
      message.title = object.title ?? "";
      message.description = object.description ?? "";
      message.logoUrl = object.logoUrl ?? "";
      message.locale = object.locale ?? "";
      return message;
    },
  };

function createBaseWorkspaceSetting_StorageSetting(): WorkspaceSetting_StorageSetting {
  return {
    storageType: WorkspaceSetting_StorageSetting_StorageType.STORAGE_TYPE_UNSPECIFIED,
    filepathTemplate: "",
    uploadSizeLimitMb: 0,
    s3Config: undefined,
  };
}

export const WorkspaceSetting_StorageSetting: MessageFns<WorkspaceSetting_StorageSetting> = {
  encode(message: WorkspaceSetting_StorageSetting, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
    if (message.storageType !== WorkspaceSetting_StorageSetting_StorageType.STORAGE_TYPE_UNSPECIFIED) {
      writer.uint32(8).int32(workspaceSetting_StorageSetting_StorageTypeToNumber(message.storageType));
    }
    if (message.filepathTemplate !== "") {
      writer.uint32(18).string(message.filepathTemplate);
    }
    if (message.uploadSizeLimitMb !== 0) {
      writer.uint32(24).int64(message.uploadSizeLimitMb);
    }
    if (message.s3Config !== undefined) {
      WorkspaceSetting_StorageSetting_S3Config.encode(message.s3Config, writer.uint32(34).fork()).join();
    }
    return writer;
  },

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

          message.storageType = workspaceSetting_StorageSetting_StorageTypeFromJSON(reader.int32());
          continue;
        }
        case 2: {
          if (tag !== 18) {
            break;
          }

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

          message.uploadSizeLimitMb = longToNumber(reader.int64());
          continue;
        }
        case 4: {
          if (tag !== 34) {
            break;
          }

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

  create(base?: DeepPartial<WorkspaceSetting_StorageSetting>): WorkspaceSetting_StorageSetting {
    return WorkspaceSetting_StorageSetting.fromPartial(base ?? {});
  },
  fromPartial(object: DeepPartial<WorkspaceSetting_StorageSetting>): WorkspaceSetting_StorageSetting {
    const message = createBaseWorkspaceSetting_StorageSetting();
    message.storageType = object.storageType ?? WorkspaceSetting_StorageSetting_StorageType.STORAGE_TYPE_UNSPECIFIED;
    message.filepathTemplate = object.filepathTemplate ?? "";
    message.uploadSizeLimitMb = object.uploadSizeLimitMb ?? 0;
    message.s3Config = (object.s3Config !== undefined && object.s3Config !== null)
      ? WorkspaceSetting_StorageSetting_S3Config.fromPartial(object.s3Config)
      : undefined;
    return message;
  },
};

function createBaseWorkspaceSetting_StorageSetting_S3Config(): WorkspaceSetting_StorageSetting_S3Config {
  return { accessKeyId: "", accessKeySecret: "", endpoint: "", region: "", bucket: "", usePathStyle: false };
}

export const WorkspaceSetting_StorageSetting_S3Config: MessageFns<WorkspaceSetting_StorageSetting_S3Config> = {
  encode(message: WorkspaceSetting_StorageSetting_S3Config, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
    if (message.accessKeyId !== "") {
      writer.uint32(10).string(message.accessKeyId);
    }
    if (message.accessKeySecret !== "") {
      writer.uint32(18).string(message.accessKeySecret);
    }
    if (message.endpoint !== "") {
      writer.uint32(26).string(message.endpoint);
    }
    if (message.region !== "") {
      writer.uint32(34).string(message.region);
    }
    if (message.bucket !== "") {
      writer.uint32(42).string(message.bucket);
    }
    if (message.usePathStyle !== false) {
      writer.uint32(48).bool(message.usePathStyle);
    }
    return writer;
  },

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

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

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

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

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

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

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

  create(base?: DeepPartial<WorkspaceSetting_StorageSetting_S3Config>): WorkspaceSetting_StorageSetting_S3Config {
    return WorkspaceSetting_StorageSetting_S3Config.fromPartial(base ?? {});
  },
  fromPartial(object: DeepPartial<WorkspaceSetting_StorageSetting_S3Config>): WorkspaceSetting_StorageSetting_S3Config {
    const message = createBaseWorkspaceSetting_StorageSetting_S3Config();
    message.accessKeyId = object.accessKeyId ?? "";
    message.accessKeySecret = object.accessKeySecret ?? "";
    message.endpoint = object.endpoint ?? "";
    message.region = object.region ?? "";
    message.bucket = object.bucket ?? "";
    message.usePathStyle = object.usePathStyle ?? false;
    return message;
  },
};

function createBaseWorkspaceSetting_MemoRelatedSetting(): WorkspaceSetting_MemoRelatedSetting {
  return {
    disallowPublicVisibility: false,
    displayWithUpdateTime: false,
    contentLengthLimit: 0,
    enableDoubleClickEdit: false,
    enableLinkPreview: false,
    reactions: [],
    disableMarkdownShortcuts: false,
    enableBlurNsfwContent: false,
    nsfwTags: [],
  };
}

export const WorkspaceSetting_MemoRelatedSetting: MessageFns<WorkspaceSetting_MemoRelatedSetting> = {
  encode(message: WorkspaceSetting_MemoRelatedSetting, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
    if (message.disallowPublicVisibility !== false) {
      writer.uint32(8).bool(message.disallowPublicVisibility);
    }
    if (message.displayWithUpdateTime !== false) {
      writer.uint32(16).bool(message.displayWithUpdateTime);
    }
    if (message.contentLengthLimit !== 0) {
      writer.uint32(24).int32(message.contentLengthLimit);
    }
    if (message.enableDoubleClickEdit !== false) {
      writer.uint32(32).bool(message.enableDoubleClickEdit);
    }
    if (message.enableLinkPreview !== false) {
      writer.uint32(40).bool(message.enableLinkPreview);
    }
    for (const v of message.reactions) {
      writer.uint32(58).string(v!);
    }
    if (message.disableMarkdownShortcuts !== false) {
      writer.uint32(64).bool(message.disableMarkdownShortcuts);
    }
    if (message.enableBlurNsfwContent !== false) {
      writer.uint32(72).bool(message.enableBlurNsfwContent);
    }
    for (const v of message.nsfwTags) {
      writer.uint32(82).string(v!);
    }
    return writer;
  },

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

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

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

          message.contentLengthLimit = reader.int32();
          continue;
        }
        case 4: {
          if (tag !== 32) {
            break;
          }

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

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

          message.reactions.push(reader.string());
          continue;
        }
        case 8: {
          if (tag !== 64) {
            break;
          }

          message.disableMarkdownShortcuts = reader.bool();
          continue;
        }
        case 9: {
          if (tag !== 72) {
            break;
          }

          message.enableBlurNsfwContent = reader.bool();
          continue;
        }
        case 10: {
          if (tag !== 82) {
            break;
          }

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

  create(base?: DeepPartial<WorkspaceSetting_MemoRelatedSetting>): WorkspaceSetting_MemoRelatedSetting {
    return WorkspaceSetting_MemoRelatedSetting.fromPartial(base ?? {});
  },
  fromPartial(object: DeepPartial<WorkspaceSetting_MemoRelatedSetting>): WorkspaceSetting_MemoRelatedSetting {
    const message = createBaseWorkspaceSetting_MemoRelatedSetting();
    message.disallowPublicVisibility = object.disallowPublicVisibility ?? false;
    message.displayWithUpdateTime = object.displayWithUpdateTime ?? false;
    message.contentLengthLimit = object.contentLengthLimit ?? 0;
    message.enableDoubleClickEdit = object.enableDoubleClickEdit ?? false;
    message.enableLinkPreview = object.enableLinkPreview ?? false;
    message.reactions = object.reactions?.map((e) => e) || [];
    message.disableMarkdownShortcuts = object.disableMarkdownShortcuts ?? false;
    message.enableBlurNsfwContent = object.enableBlurNsfwContent ?? false;
    message.nsfwTags = object.nsfwTags?.map((e) => e) || [];
    return message;
  },
};

function createBaseGetWorkspaceSettingRequest(): GetWorkspaceSettingRequest {
  return { name: "" };
}

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

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

  create(base?: DeepPartial<GetWorkspaceSettingRequest>): GetWorkspaceSettingRequest {
    return GetWorkspaceSettingRequest.fromPartial(base ?? {});
  },
  fromPartial(object: DeepPartial<GetWorkspaceSettingRequest>): GetWorkspaceSettingRequest {
    const message = createBaseGetWorkspaceSettingRequest();
    message.name = object.name ?? "";
    return message;
  },
};

function createBaseUpdateWorkspaceSettingRequest(): UpdateWorkspaceSettingRequest {
  return { setting: undefined, updateMask: undefined };
}

export const UpdateWorkspaceSettingRequest: MessageFns<UpdateWorkspaceSettingRequest> = {
  encode(message: UpdateWorkspaceSettingRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
    if (message.setting !== undefined) {
      WorkspaceSetting.encode(message.setting, writer.uint32(10).fork()).join();
    }
    if (message.updateMask !== undefined) {
      FieldMask.encode(FieldMask.wrap(message.updateMask), writer.uint32(18).fork()).join();
    }
    return writer;
  },

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

          message.setting = WorkspaceSetting.decode(reader, reader.uint32());
          continue;
        }
        case 2: {
          if (tag !== 18) {
            break;
          }

          message.updateMask = FieldMask.unwrap(FieldMask.decode(reader, reader.uint32()));
          continue;
        }
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skip(tag & 7);
    }
    return message;
  },

  create(base?: DeepPartial<UpdateWorkspaceSettingRequest>): UpdateWorkspaceSettingRequest {
    return UpdateWorkspaceSettingRequest.fromPartial(base ?? {});
  },
  fromPartial(object: DeepPartial<UpdateWorkspaceSettingRequest>): UpdateWorkspaceSettingRequest {
    const message = createBaseUpdateWorkspaceSettingRequest();
    message.setting = (object.setting !== undefined && object.setting !== null)
      ? WorkspaceSetting.fromPartial(object.setting)
      : undefined;
    message.updateMask = object.updateMask ?? undefined;
    return message;
  },
};

export type WorkspaceServiceDefinition = typeof WorkspaceServiceDefinition;
export const WorkspaceServiceDefinition = {
  name: "WorkspaceService",
  fullName: "memos.api.v1.WorkspaceService",
  methods: {
    /** Gets the workspace profile. */
    getWorkspaceProfile: {
      name: "GetWorkspaceProfile",
      requestType: GetWorkspaceProfileRequest,
      requestStream: false,
      responseType: WorkspaceProfile,
      responseStream: false,
      options: {
        _unknownFields: {
          578365826: [
            new Uint8Array([
              27,
              18,
              25,
              47,
              97,
              112,
              105,
              47,
              118,
              49,
              47,
              119,
              111,
              114,
              107,
              115,
              112,
              97,
              99,
              101,
              47,
              112,
              114,
              111,
              102,
              105,
              108,
              101,
            ]),
          ],
        },
      },
    },
    /** Gets a workspace setting. */
    getWorkspaceSetting: {
      name: "GetWorkspaceSetting",
      requestType: GetWorkspaceSettingRequest,
      requestStream: false,
      responseType: WorkspaceSetting,
      responseStream: false,
      options: {
        _unknownFields: {
          8410: [new Uint8Array([4, 110, 97, 109, 101])],
          578365826: [
            new Uint8Array([
              37,
              18,
              35,
              47,
              97,
              112,
              105,
              47,
              118,
              49,
              47,
              123,
              110,
              97,
              109,
              101,
              61,
              119,
              111,
              114,
              107,
              115,
              112,
              97,
              99,
              101,
              47,
              115,
              101,
              116,
              116,
              105,
              110,
              103,
              115,
              47,
              42,
              125,
            ]),
          ],
        },
      },
    },
    /** Updates a workspace setting. */
    updateWorkspaceSetting: {
      name: "UpdateWorkspaceSetting",
      requestType: UpdateWorkspaceSettingRequest,
      requestStream: false,
      responseType: WorkspaceSetting,
      responseStream: false,
      options: {
        _unknownFields: {
          8410: [
            new Uint8Array([
              19,
              115,
              101,
              116,
              116,
              105,
              110,
              103,
              44,
              117,
              112,
              100,
              97,
              116,
              101,
              95,
              109,
              97,
              115,
              107,
            ]),
          ],
          578365826: [
            new Uint8Array([
              54,
              58,
              7,
              115,
              101,
              116,
              116,
              105,
              110,
              103,
              50,
              43,
              47,
              97,
              112,
              105,
              47,
              118,
              49,
              47,
              123,
              115,
              101,
              116,
              116,
              105,
              110,
              103,
              46,
              110,
              97,
              109,
              101,
              61,
              119,
              111,
              114,
              107,
              115,
              112,
              97,
              99,
              101,
              47,
              115,
              101,
              116,
              116,
              105,
              110,
              103,
              115,
              47,
              42,
              125,
            ]),
          ],
        },
      },
    },
  },
} as const;

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

function longToNumber(int64: { toString(): string }): number {
  const num = globalThis.Number(int64.toString());
  if (num > globalThis.Number.MAX_SAFE_INTEGER) {
    throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
  }
  if (num < globalThis.Number.MIN_SAFE_INTEGER) {
    throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER");
  }
  return num;
}

export interface MessageFns<T> {
  encode(message: T, writer?: BinaryWriter): BinaryWriter;
  decode(input: BinaryReader | Uint8Array, length?: number): T;
  create(base?: DeepPartial<T>): T;
  fromPartial(object: DeepPartial<T>): T;
}
