// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
//   protoc-gen-ts_proto  v2.8.0
//   protoc               v3.21.12
// source: fsentry.proto

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

export const protobufPackage = "";

/**
 * The FSEntry from client's (puter-js, http API) perspective, it's used for
 * - end to end test
 * - backend logic
 * - communication between servers
 */
export interface FSEntry {
  uuid: string;
  /** Same as uuid, used for backward compatibility. */
  uid: string;
  name: string;
  path: string;
  parent_uuid: string;
  /** Same as parent_uuid, used for backward compatibility. */
  parent_uid: string;
  /** Same as parent_uuid, used for backward compatibility. */
  parent_id: string;
  is_dir: boolean;
  created: number;
  modified: number;
  accessed: number;
  size: number;
}

function createBaseFSEntry(): FSEntry {
  return {
    uuid: "",
    uid: "",
    name: "",
    path: "",
    parent_uuid: "",
    parent_uid: "",
    parent_id: "",
    is_dir: false,
    created: 0,
    modified: 0,
    accessed: 0,
    size: 0,
  };
}

export const FSEntry: MessageFns<FSEntry> = {
  encode(message: FSEntry, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
    if (message.uuid !== "") {
      writer.uint32(10).string(message.uuid);
    }
    if (message.uid !== "") {
      writer.uint32(18).string(message.uid);
    }
    if (message.name !== "") {
      writer.uint32(26).string(message.name);
    }
    if (message.path !== "") {
      writer.uint32(34).string(message.path);
    }
    if (message.parent_uuid !== "") {
      writer.uint32(42).string(message.parent_uuid);
    }
    if (message.parent_uid !== "") {
      writer.uint32(50).string(message.parent_uid);
    }
    if (message.parent_id !== "") {
      writer.uint32(58).string(message.parent_id);
    }
    if (message.is_dir !== false) {
      writer.uint32(64).bool(message.is_dir);
    }
    if (message.created !== 0) {
      writer.uint32(72).int64(message.created);
    }
    if (message.modified !== 0) {
      writer.uint32(80).int64(message.modified);
    }
    if (message.accessed !== 0) {
      writer.uint32(88).int64(message.accessed);
    }
    if (message.size !== 0) {
      writer.uint32(96).int64(message.size);
    }
    return writer;
  },

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

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

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

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

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

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

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

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

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

          message.created = longToNumber(reader.int64());
          continue;
        }
        case 10: {
          if (tag !== 80) {
            break;
          }

          message.modified = longToNumber(reader.int64());
          continue;
        }
        case 11: {
          if (tag !== 88) {
            break;
          }

          message.accessed = longToNumber(reader.int64());
          continue;
        }
        case 12: {
          if (tag !== 96) {
            break;
          }

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

  fromJSON(object: any): FSEntry {
    return {
      uuid: isSet(object.uuid) ? globalThis.String(object.uuid) : "",
      uid: isSet(object.uid) ? globalThis.String(object.uid) : "",
      name: isSet(object.name) ? globalThis.String(object.name) : "",
      path: isSet(object.path) ? globalThis.String(object.path) : "",
      parent_uuid: isSet(object.parent_uuid) ? globalThis.String(object.parent_uuid) : "",
      parent_uid: isSet(object.parent_uid) ? globalThis.String(object.parent_uid) : "",
      parent_id: isSet(object.parent_id) ? globalThis.String(object.parent_id) : "",
      is_dir: isSet(object.is_dir) ? globalThis.Boolean(object.is_dir) : false,
      created: isSet(object.created) ? globalThis.Number(object.created) : 0,
      modified: isSet(object.modified) ? globalThis.Number(object.modified) : 0,
      accessed: isSet(object.accessed) ? globalThis.Number(object.accessed) : 0,
      size: isSet(object.size) ? globalThis.Number(object.size) : 0,
    };
  },

  toJSON(message: FSEntry): unknown {
    const obj: any = {};
    if (message.uuid !== "") {
      obj.uuid = message.uuid;
    }
    if (message.uid !== "") {
      obj.uid = message.uid;
    }
    if (message.name !== "") {
      obj.name = message.name;
    }
    if (message.path !== "") {
      obj.path = message.path;
    }
    if (message.parent_uuid !== "") {
      obj.parent_uuid = message.parent_uuid;
    }
    if (message.parent_uid !== "") {
      obj.parent_uid = message.parent_uid;
    }
    if (message.parent_id !== "") {
      obj.parent_id = message.parent_id;
    }
    if (message.is_dir !== false) {
      obj.is_dir = message.is_dir;
    }
    if (message.created !== 0) {
      obj.created = Math.round(message.created);
    }
    if (message.modified !== 0) {
      obj.modified = Math.round(message.modified);
    }
    if (message.accessed !== 0) {
      obj.accessed = Math.round(message.accessed);
    }
    if (message.size !== 0) {
      obj.size = Math.round(message.size);
    }
    return obj;
  },

  create(base?: DeepPartial<FSEntry>): FSEntry {
    return FSEntry.fromPartial(base ?? {});
  },
  fromPartial(object: DeepPartial<FSEntry>): FSEntry {
    const message = createBaseFSEntry();
    message.uuid = object.uuid ?? "";
    message.uid = object.uid ?? "";
    message.name = object.name ?? "";
    message.path = object.path ?? "";
    message.parent_uuid = object.parent_uuid ?? "";
    message.parent_uid = object.parent_uid ?? "";
    message.parent_id = object.parent_id ?? "";
    message.is_dir = object.is_dir ?? false;
    message.created = object.created ?? 0;
    message.modified = object.modified ?? 0;
    message.accessed = object.accessed ?? 0;
    message.size = object.size ?? 0;
    return message;
  },
};

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

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(base?: DeepPartial<T>): T;
  fromPartial(object: DeepPartial<T>): T;
}
