import { WireType } from "@protobuf-ts/runtime";
import { UnknownFieldHandler } from "@protobuf-ts/runtime";
import { reflectionMergePartial } from "@protobuf-ts/runtime";
import { MessageType } from "@protobuf-ts/runtime";
import { Duration } from "../../protobuf/duration.js";
import { Timestamp } from "../../protobuf/timestamp.js";
import { Struct } from "../../protobuf/struct.js";
import { Any } from "../../protobuf/any.js";
class AttributeContext$Type extends MessageType {
  constructor() {
    super("google.rpc.context.AttributeContext", [
      {
        no: 7,
        name: "origin",
        kind: "message",
        T: () => AttributeContext_Peer
      },
      {
        no: 1,
        name: "source",
        kind: "message",
        T: () => AttributeContext_Peer
      },
      {
        no: 2,
        name: "destination",
        kind: "message",
        T: () => AttributeContext_Peer
      },
      {
        no: 3,
        name: "request",
        kind: "message",
        T: () => AttributeContext_Request
      },
      {
        no: 4,
        name: "response",
        kind: "message",
        T: () => AttributeContext_Response
      },
      {
        no: 5,
        name: "resource",
        kind: "message",
        T: () => AttributeContext_Resource
      },
      {
        no: 6,
        name: "api",
        kind: "message",
        T: () => AttributeContext_Api
      },
      {
        no: 8,
        name: "extensions",
        kind: "message",
        repeat: 2,
        T: () => Any
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.extensions = [];
    if (value !== void 0)
      reflectionMergePartial(this, message, value);
    return message;
  }
  internalBinaryRead(reader, length, options, target) {
    let message = target ?? this.create(), end = reader.pos + length;
    while (reader.pos < end) {
      let [fieldNo, wireType] = reader.tag();
      switch (fieldNo) {
        case /* google.rpc.context.AttributeContext.Peer origin */
        7:
          message.origin = AttributeContext_Peer.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.origin
          );
          break;
        case /* google.rpc.context.AttributeContext.Peer source */
        1:
          message.source = AttributeContext_Peer.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.source
          );
          break;
        case /* google.rpc.context.AttributeContext.Peer destination */
        2:
          message.destination = AttributeContext_Peer.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.destination
          );
          break;
        case /* google.rpc.context.AttributeContext.Request request */
        3:
          message.request = AttributeContext_Request.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.request
          );
          break;
        case /* google.rpc.context.AttributeContext.Response response */
        4:
          message.response = AttributeContext_Response.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.response
          );
          break;
        case /* google.rpc.context.AttributeContext.Resource resource */
        5:
          message.resource = AttributeContext_Resource.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.resource
          );
          break;
        case /* google.rpc.context.AttributeContext.Api api */
        6:
          message.api = AttributeContext_Api.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.api
          );
          break;
        case /* repeated google.protobuf.Any extensions */
        8:
          message.extensions.push(
            Any.internalBinaryRead(reader, reader.uint32(), options)
          );
          break;
        default:
          let u = options.readUnknownField;
          if (u === "throw")
            throw new globalThis.Error(
              `Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`
            );
          let d = reader.skip(wireType);
          if (u !== false)
            (u === true ? UnknownFieldHandler.onRead : u)(
              this.typeName,
              message,
              fieldNo,
              wireType,
              d
            );
      }
    }
    return message;
  }
  internalBinaryWrite(message, writer, options) {
    if (message.source)
      AttributeContext_Peer.internalBinaryWrite(
        message.source,
        writer.tag(1, WireType.LengthDelimited).fork(),
        options
      ).join();
    if (message.destination)
      AttributeContext_Peer.internalBinaryWrite(
        message.destination,
        writer.tag(2, WireType.LengthDelimited).fork(),
        options
      ).join();
    if (message.request)
      AttributeContext_Request.internalBinaryWrite(
        message.request,
        writer.tag(3, WireType.LengthDelimited).fork(),
        options
      ).join();
    if (message.response)
      AttributeContext_Response.internalBinaryWrite(
        message.response,
        writer.tag(4, WireType.LengthDelimited).fork(),
        options
      ).join();
    if (message.resource)
      AttributeContext_Resource.internalBinaryWrite(
        message.resource,
        writer.tag(5, WireType.LengthDelimited).fork(),
        options
      ).join();
    if (message.api)
      AttributeContext_Api.internalBinaryWrite(
        message.api,
        writer.tag(6, WireType.LengthDelimited).fork(),
        options
      ).join();
    if (message.origin)
      AttributeContext_Peer.internalBinaryWrite(
        message.origin,
        writer.tag(7, WireType.LengthDelimited).fork(),
        options
      ).join();
    for (let i = 0; i < message.extensions.length; i++)
      Any.internalBinaryWrite(
        message.extensions[i],
        writer.tag(8, WireType.LengthDelimited).fork(),
        options
      ).join();
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const AttributeContext = new AttributeContext$Type();
class AttributeContext_Peer$Type extends MessageType {
  constructor() {
    super("google.rpc.context.AttributeContext.Peer", [
      {
        no: 1,
        name: "ip",
        kind: "scalar",
        T: 9
        /*ScalarType.STRING*/
      },
      {
        no: 2,
        name: "port",
        kind: "scalar",
        T: 3,
        L: 0
      },
      {
        no: 6,
        name: "labels",
        kind: "map",
        K: 9,
        V: {
          kind: "scalar",
          T: 9
          /*ScalarType.STRING*/
        }
      },
      {
        no: 7,
        name: "principal",
        kind: "scalar",
        T: 9
      },
      {
        no: 8,
        name: "region_code",
        kind: "scalar",
        T: 9
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.ip = "";
    message.port = 0n;
    message.labels = {};
    message.principal = "";
    message.regionCode = "";
    if (value !== void 0)
      reflectionMergePartial(this, message, value);
    return message;
  }
  internalBinaryRead(reader, length, options, target) {
    let message = target ?? this.create(), end = reader.pos + length;
    while (reader.pos < end) {
      let [fieldNo, wireType] = reader.tag();
      switch (fieldNo) {
        case /* string ip */
        1:
          message.ip = reader.string();
          break;
        case /* int64 port */
        2:
          message.port = reader.int64().toBigInt();
          break;
        case /* map<string, string> labels */
        6:
          this.binaryReadMap6(message.labels, reader, options);
          break;
        case /* string principal */
        7:
          message.principal = reader.string();
          break;
        case /* string region_code */
        8:
          message.regionCode = reader.string();
          break;
        default:
          let u = options.readUnknownField;
          if (u === "throw")
            throw new globalThis.Error(
              `Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`
            );
          let d = reader.skip(wireType);
          if (u !== false)
            (u === true ? UnknownFieldHandler.onRead : u)(
              this.typeName,
              message,
              fieldNo,
              wireType,
              d
            );
      }
    }
    return message;
  }
  binaryReadMap6(map, reader, options) {
    let len = reader.uint32(), end = reader.pos + len, key, val;
    while (reader.pos < end) {
      let [fieldNo, wireType] = reader.tag();
      switch (fieldNo) {
        case 1:
          key = reader.string();
          break;
        case 2:
          val = reader.string();
          break;
        default:
          throw new globalThis.Error(
            "unknown map entry field for google.rpc.context.AttributeContext.Peer.labels"
          );
      }
    }
    map[key ?? ""] = val ?? "";
  }
  internalBinaryWrite(message, writer, options) {
    if (message.ip !== "")
      writer.tag(1, WireType.LengthDelimited).string(message.ip);
    if (message.port !== 0n)
      writer.tag(2, WireType.Varint).int64(message.port);
    for (let k of globalThis.Object.keys(message.labels))
      writer.tag(6, WireType.LengthDelimited).fork().tag(1, WireType.LengthDelimited).string(k).tag(2, WireType.LengthDelimited).string(message.labels[k]).join();
    if (message.principal !== "")
      writer.tag(7, WireType.LengthDelimited).string(message.principal);
    if (message.regionCode !== "")
      writer.tag(8, WireType.LengthDelimited).string(message.regionCode);
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const AttributeContext_Peer = new AttributeContext_Peer$Type();
class AttributeContext_Api$Type extends MessageType {
  constructor() {
    super("google.rpc.context.AttributeContext.Api", [
      {
        no: 1,
        name: "service",
        kind: "scalar",
        T: 9
      },
      {
        no: 2,
        name: "operation",
        kind: "scalar",
        T: 9
      },
      {
        no: 3,
        name: "protocol",
        kind: "scalar",
        T: 9
      },
      {
        no: 4,
        name: "version",
        kind: "scalar",
        T: 9
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.service = "";
    message.operation = "";
    message.protocol = "";
    message.version = "";
    if (value !== void 0)
      reflectionMergePartial(this, message, value);
    return message;
  }
  internalBinaryRead(reader, length, options, target) {
    let message = target ?? this.create(), end = reader.pos + length;
    while (reader.pos < end) {
      let [fieldNo, wireType] = reader.tag();
      switch (fieldNo) {
        case /* string service */
        1:
          message.service = reader.string();
          break;
        case /* string operation */
        2:
          message.operation = reader.string();
          break;
        case /* string protocol */
        3:
          message.protocol = reader.string();
          break;
        case /* string version */
        4:
          message.version = reader.string();
          break;
        default:
          let u = options.readUnknownField;
          if (u === "throw")
            throw new globalThis.Error(
              `Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`
            );
          let d = reader.skip(wireType);
          if (u !== false)
            (u === true ? UnknownFieldHandler.onRead : u)(
              this.typeName,
              message,
              fieldNo,
              wireType,
              d
            );
      }
    }
    return message;
  }
  internalBinaryWrite(message, writer, options) {
    if (message.service !== "")
      writer.tag(1, WireType.LengthDelimited).string(message.service);
    if (message.operation !== "")
      writer.tag(2, WireType.LengthDelimited).string(message.operation);
    if (message.protocol !== "")
      writer.tag(3, WireType.LengthDelimited).string(message.protocol);
    if (message.version !== "")
      writer.tag(4, WireType.LengthDelimited).string(message.version);
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const AttributeContext_Api = new AttributeContext_Api$Type();
class AttributeContext_Auth$Type extends MessageType {
  constructor() {
    super("google.rpc.context.AttributeContext.Auth", [
      {
        no: 1,
        name: "principal",
        kind: "scalar",
        T: 9
      },
      {
        no: 2,
        name: "audiences",
        kind: "scalar",
        repeat: 2,
        T: 9
      },
      {
        no: 3,
        name: "presenter",
        kind: "scalar",
        T: 9
      },
      { no: 4, name: "claims", kind: "message", T: () => Struct },
      {
        no: 5,
        name: "access_levels",
        kind: "scalar",
        repeat: 2,
        T: 9
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.principal = "";
    message.audiences = [];
    message.presenter = "";
    message.accessLevels = [];
    if (value !== void 0)
      reflectionMergePartial(this, message, value);
    return message;
  }
  internalBinaryRead(reader, length, options, target) {
    let message = target ?? this.create(), end = reader.pos + length;
    while (reader.pos < end) {
      let [fieldNo, wireType] = reader.tag();
      switch (fieldNo) {
        case /* string principal */
        1:
          message.principal = reader.string();
          break;
        case /* repeated string audiences */
        2:
          message.audiences.push(reader.string());
          break;
        case /* string presenter */
        3:
          message.presenter = reader.string();
          break;
        case /* google.protobuf.Struct claims */
        4:
          message.claims = Struct.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.claims
          );
          break;
        case /* repeated string access_levels */
        5:
          message.accessLevels.push(reader.string());
          break;
        default:
          let u = options.readUnknownField;
          if (u === "throw")
            throw new globalThis.Error(
              `Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`
            );
          let d = reader.skip(wireType);
          if (u !== false)
            (u === true ? UnknownFieldHandler.onRead : u)(
              this.typeName,
              message,
              fieldNo,
              wireType,
              d
            );
      }
    }
    return message;
  }
  internalBinaryWrite(message, writer, options) {
    if (message.principal !== "")
      writer.tag(1, WireType.LengthDelimited).string(message.principal);
    for (let i = 0; i < message.audiences.length; i++)
      writer.tag(2, WireType.LengthDelimited).string(message.audiences[i]);
    if (message.presenter !== "")
      writer.tag(3, WireType.LengthDelimited).string(message.presenter);
    if (message.claims)
      Struct.internalBinaryWrite(
        message.claims,
        writer.tag(4, WireType.LengthDelimited).fork(),
        options
      ).join();
    for (let i = 0; i < message.accessLevels.length; i++)
      writer.tag(5, WireType.LengthDelimited).string(message.accessLevels[i]);
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const AttributeContext_Auth = new AttributeContext_Auth$Type();
class AttributeContext_Request$Type extends MessageType {
  constructor() {
    super("google.rpc.context.AttributeContext.Request", [
      {
        no: 1,
        name: "id",
        kind: "scalar",
        T: 9
        /*ScalarType.STRING*/
      },
      {
        no: 2,
        name: "method",
        kind: "scalar",
        T: 9
      },
      {
        no: 3,
        name: "headers",
        kind: "map",
        K: 9,
        V: {
          kind: "scalar",
          T: 9
          /*ScalarType.STRING*/
        }
      },
      {
        no: 4,
        name: "path",
        kind: "scalar",
        T: 9
        /*ScalarType.STRING*/
      },
      {
        no: 5,
        name: "host",
        kind: "scalar",
        T: 9
        /*ScalarType.STRING*/
      },
      {
        no: 6,
        name: "scheme",
        kind: "scalar",
        T: 9
      },
      {
        no: 7,
        name: "query",
        kind: "scalar",
        T: 9
      },
      { no: 9, name: "time", kind: "message", T: () => Timestamp },
      {
        no: 10,
        name: "size",
        kind: "scalar",
        T: 3,
        L: 0
      },
      {
        no: 11,
        name: "protocol",
        kind: "scalar",
        T: 9
      },
      {
        no: 12,
        name: "reason",
        kind: "scalar",
        T: 9
      },
      {
        no: 13,
        name: "auth",
        kind: "message",
        T: () => AttributeContext_Auth
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.id = "";
    message.method = "";
    message.headers = {};
    message.path = "";
    message.host = "";
    message.scheme = "";
    message.query = "";
    message.size = 0n;
    message.protocol = "";
    message.reason = "";
    if (value !== void 0)
      reflectionMergePartial(
        this,
        message,
        value
      );
    return message;
  }
  internalBinaryRead(reader, length, options, target) {
    let message = target ?? this.create(), end = reader.pos + length;
    while (reader.pos < end) {
      let [fieldNo, wireType] = reader.tag();
      switch (fieldNo) {
        case /* string id */
        1:
          message.id = reader.string();
          break;
        case /* string method */
        2:
          message.method = reader.string();
          break;
        case /* map<string, string> headers */
        3:
          this.binaryReadMap3(message.headers, reader, options);
          break;
        case /* string path */
        4:
          message.path = reader.string();
          break;
        case /* string host */
        5:
          message.host = reader.string();
          break;
        case /* string scheme */
        6:
          message.scheme = reader.string();
          break;
        case /* string query */
        7:
          message.query = reader.string();
          break;
        case /* google.protobuf.Timestamp time */
        9:
          message.time = Timestamp.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.time
          );
          break;
        case /* int64 size */
        10:
          message.size = reader.int64().toBigInt();
          break;
        case /* string protocol */
        11:
          message.protocol = reader.string();
          break;
        case /* string reason */
        12:
          message.reason = reader.string();
          break;
        case /* google.rpc.context.AttributeContext.Auth auth */
        13:
          message.auth = AttributeContext_Auth.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.auth
          );
          break;
        default:
          let u = options.readUnknownField;
          if (u === "throw")
            throw new globalThis.Error(
              `Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`
            );
          let d = reader.skip(wireType);
          if (u !== false)
            (u === true ? UnknownFieldHandler.onRead : u)(
              this.typeName,
              message,
              fieldNo,
              wireType,
              d
            );
      }
    }
    return message;
  }
  binaryReadMap3(map, reader, options) {
    let len = reader.uint32(), end = reader.pos + len, key, val;
    while (reader.pos < end) {
      let [fieldNo, wireType] = reader.tag();
      switch (fieldNo) {
        case 1:
          key = reader.string();
          break;
        case 2:
          val = reader.string();
          break;
        default:
          throw new globalThis.Error(
            "unknown map entry field for google.rpc.context.AttributeContext.Request.headers"
          );
      }
    }
    map[key ?? ""] = val ?? "";
  }
  internalBinaryWrite(message, writer, options) {
    if (message.id !== "")
      writer.tag(1, WireType.LengthDelimited).string(message.id);
    if (message.method !== "")
      writer.tag(2, WireType.LengthDelimited).string(message.method);
    for (let k of globalThis.Object.keys(message.headers))
      writer.tag(3, WireType.LengthDelimited).fork().tag(1, WireType.LengthDelimited).string(k).tag(2, WireType.LengthDelimited).string(message.headers[k]).join();
    if (message.path !== "")
      writer.tag(4, WireType.LengthDelimited).string(message.path);
    if (message.host !== "")
      writer.tag(5, WireType.LengthDelimited).string(message.host);
    if (message.scheme !== "")
      writer.tag(6, WireType.LengthDelimited).string(message.scheme);
    if (message.query !== "")
      writer.tag(7, WireType.LengthDelimited).string(message.query);
    if (message.time)
      Timestamp.internalBinaryWrite(
        message.time,
        writer.tag(9, WireType.LengthDelimited).fork(),
        options
      ).join();
    if (message.size !== 0n)
      writer.tag(10, WireType.Varint).int64(message.size);
    if (message.protocol !== "")
      writer.tag(11, WireType.LengthDelimited).string(message.protocol);
    if (message.reason !== "")
      writer.tag(12, WireType.LengthDelimited).string(message.reason);
    if (message.auth)
      AttributeContext_Auth.internalBinaryWrite(
        message.auth,
        writer.tag(13, WireType.LengthDelimited).fork(),
        options
      ).join();
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const AttributeContext_Request = new AttributeContext_Request$Type();
class AttributeContext_Response$Type extends MessageType {
  constructor() {
    super("google.rpc.context.AttributeContext.Response", [
      {
        no: 1,
        name: "code",
        kind: "scalar",
        T: 3,
        L: 0
      },
      {
        no: 2,
        name: "size",
        kind: "scalar",
        T: 3,
        L: 0
      },
      {
        no: 3,
        name: "headers",
        kind: "map",
        K: 9,
        V: {
          kind: "scalar",
          T: 9
          /*ScalarType.STRING*/
        }
      },
      { no: 4, name: "time", kind: "message", T: () => Timestamp },
      {
        no: 5,
        name: "backend_latency",
        kind: "message",
        T: () => Duration
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.code = 0n;
    message.size = 0n;
    message.headers = {};
    if (value !== void 0)
      reflectionMergePartial(
        this,
        message,
        value
      );
    return message;
  }
  internalBinaryRead(reader, length, options, target) {
    let message = target ?? this.create(), end = reader.pos + length;
    while (reader.pos < end) {
      let [fieldNo, wireType] = reader.tag();
      switch (fieldNo) {
        case /* int64 code */
        1:
          message.code = reader.int64().toBigInt();
          break;
        case /* int64 size */
        2:
          message.size = reader.int64().toBigInt();
          break;
        case /* map<string, string> headers */
        3:
          this.binaryReadMap3(message.headers, reader, options);
          break;
        case /* google.protobuf.Timestamp time */
        4:
          message.time = Timestamp.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.time
          );
          break;
        case /* google.protobuf.Duration backend_latency */
        5:
          message.backendLatency = Duration.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.backendLatency
          );
          break;
        default:
          let u = options.readUnknownField;
          if (u === "throw")
            throw new globalThis.Error(
              `Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`
            );
          let d = reader.skip(wireType);
          if (u !== false)
            (u === true ? UnknownFieldHandler.onRead : u)(
              this.typeName,
              message,
              fieldNo,
              wireType,
              d
            );
      }
    }
    return message;
  }
  binaryReadMap3(map, reader, options) {
    let len = reader.uint32(), end = reader.pos + len, key, val;
    while (reader.pos < end) {
      let [fieldNo, wireType] = reader.tag();
      switch (fieldNo) {
        case 1:
          key = reader.string();
          break;
        case 2:
          val = reader.string();
          break;
        default:
          throw new globalThis.Error(
            "unknown map entry field for google.rpc.context.AttributeContext.Response.headers"
          );
      }
    }
    map[key ?? ""] = val ?? "";
  }
  internalBinaryWrite(message, writer, options) {
    if (message.code !== 0n)
      writer.tag(1, WireType.Varint).int64(message.code);
    if (message.size !== 0n)
      writer.tag(2, WireType.Varint).int64(message.size);
    for (let k of globalThis.Object.keys(message.headers))
      writer.tag(3, WireType.LengthDelimited).fork().tag(1, WireType.LengthDelimited).string(k).tag(2, WireType.LengthDelimited).string(message.headers[k]).join();
    if (message.time)
      Timestamp.internalBinaryWrite(
        message.time,
        writer.tag(4, WireType.LengthDelimited).fork(),
        options
      ).join();
    if (message.backendLatency)
      Duration.internalBinaryWrite(
        message.backendLatency,
        writer.tag(5, WireType.LengthDelimited).fork(),
        options
      ).join();
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const AttributeContext_Response = new AttributeContext_Response$Type();
class AttributeContext_Resource$Type extends MessageType {
  constructor() {
    super("google.rpc.context.AttributeContext.Resource", [
      {
        no: 1,
        name: "service",
        kind: "scalar",
        T: 9
      },
      {
        no: 2,
        name: "name",
        kind: "scalar",
        T: 9
        /*ScalarType.STRING*/
      },
      {
        no: 3,
        name: "type",
        kind: "scalar",
        T: 9
        /*ScalarType.STRING*/
      },
      {
        no: 4,
        name: "labels",
        kind: "map",
        K: 9,
        V: {
          kind: "scalar",
          T: 9
          /*ScalarType.STRING*/
        }
      },
      {
        no: 5,
        name: "uid",
        kind: "scalar",
        T: 9
        /*ScalarType.STRING*/
      },
      {
        no: 6,
        name: "annotations",
        kind: "map",
        K: 9,
        V: {
          kind: "scalar",
          T: 9
          /*ScalarType.STRING*/
        }
      },
      {
        no: 7,
        name: "display_name",
        kind: "scalar",
        T: 9
      },
      { no: 8, name: "create_time", kind: "message", T: () => Timestamp },
      { no: 9, name: "update_time", kind: "message", T: () => Timestamp },
      {
        no: 10,
        name: "delete_time",
        kind: "message",
        T: () => Timestamp
      },
      {
        no: 11,
        name: "etag",
        kind: "scalar",
        T: 9
      },
      {
        no: 12,
        name: "location",
        kind: "scalar",
        T: 9
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.service = "";
    message.name = "";
    message.type = "";
    message.labels = {};
    message.uid = "";
    message.annotations = {};
    message.displayName = "";
    message.etag = "";
    message.location = "";
    if (value !== void 0)
      reflectionMergePartial(
        this,
        message,
        value
      );
    return message;
  }
  internalBinaryRead(reader, length, options, target) {
    let message = target ?? this.create(), end = reader.pos + length;
    while (reader.pos < end) {
      let [fieldNo, wireType] = reader.tag();
      switch (fieldNo) {
        case /* string service */
        1:
          message.service = reader.string();
          break;
        case /* string name */
        2:
          message.name = reader.string();
          break;
        case /* string type */
        3:
          message.type = reader.string();
          break;
        case /* map<string, string> labels */
        4:
          this.binaryReadMap4(message.labels, reader, options);
          break;
        case /* string uid */
        5:
          message.uid = reader.string();
          break;
        case /* map<string, string> annotations */
        6:
          this.binaryReadMap6(message.annotations, reader, options);
          break;
        case /* string display_name */
        7:
          message.displayName = reader.string();
          break;
        case /* google.protobuf.Timestamp create_time */
        8:
          message.createTime = Timestamp.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.createTime
          );
          break;
        case /* google.protobuf.Timestamp update_time */
        9:
          message.updateTime = Timestamp.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.updateTime
          );
          break;
        case /* google.protobuf.Timestamp delete_time */
        10:
          message.deleteTime = Timestamp.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.deleteTime
          );
          break;
        case /* string etag */
        11:
          message.etag = reader.string();
          break;
        case /* string location */
        12:
          message.location = reader.string();
          break;
        default:
          let u = options.readUnknownField;
          if (u === "throw")
            throw new globalThis.Error(
              `Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`
            );
          let d = reader.skip(wireType);
          if (u !== false)
            (u === true ? UnknownFieldHandler.onRead : u)(
              this.typeName,
              message,
              fieldNo,
              wireType,
              d
            );
      }
    }
    return message;
  }
  binaryReadMap4(map, reader, options) {
    let len = reader.uint32(), end = reader.pos + len, key, val;
    while (reader.pos < end) {
      let [fieldNo, wireType] = reader.tag();
      switch (fieldNo) {
        case 1:
          key = reader.string();
          break;
        case 2:
          val = reader.string();
          break;
        default:
          throw new globalThis.Error(
            "unknown map entry field for google.rpc.context.AttributeContext.Resource.labels"
          );
      }
    }
    map[key ?? ""] = val ?? "";
  }
  binaryReadMap6(map, reader, options) {
    let len = reader.uint32(), end = reader.pos + len, key, val;
    while (reader.pos < end) {
      let [fieldNo, wireType] = reader.tag();
      switch (fieldNo) {
        case 1:
          key = reader.string();
          break;
        case 2:
          val = reader.string();
          break;
        default:
          throw new globalThis.Error(
            "unknown map entry field for google.rpc.context.AttributeContext.Resource.annotations"
          );
      }
    }
    map[key ?? ""] = val ?? "";
  }
  internalBinaryWrite(message, writer, options) {
    if (message.service !== "")
      writer.tag(1, WireType.LengthDelimited).string(message.service);
    if (message.name !== "")
      writer.tag(2, WireType.LengthDelimited).string(message.name);
    if (message.type !== "")
      writer.tag(3, WireType.LengthDelimited).string(message.type);
    for (let k of globalThis.Object.keys(message.labels))
      writer.tag(4, WireType.LengthDelimited).fork().tag(1, WireType.LengthDelimited).string(k).tag(2, WireType.LengthDelimited).string(message.labels[k]).join();
    if (message.uid !== "")
      writer.tag(5, WireType.LengthDelimited).string(message.uid);
    for (let k of globalThis.Object.keys(message.annotations))
      writer.tag(6, WireType.LengthDelimited).fork().tag(1, WireType.LengthDelimited).string(k).tag(2, WireType.LengthDelimited).string(message.annotations[k]).join();
    if (message.displayName !== "")
      writer.tag(7, WireType.LengthDelimited).string(message.displayName);
    if (message.createTime)
      Timestamp.internalBinaryWrite(
        message.createTime,
        writer.tag(8, WireType.LengthDelimited).fork(),
        options
      ).join();
    if (message.updateTime)
      Timestamp.internalBinaryWrite(
        message.updateTime,
        writer.tag(9, WireType.LengthDelimited).fork(),
        options
      ).join();
    if (message.deleteTime)
      Timestamp.internalBinaryWrite(
        message.deleteTime,
        writer.tag(10, WireType.LengthDelimited).fork(),
        options
      ).join();
    if (message.etag !== "")
      writer.tag(11, WireType.LengthDelimited).string(message.etag);
    if (message.location !== "")
      writer.tag(12, WireType.LengthDelimited).string(message.location);
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const AttributeContext_Resource = new AttributeContext_Resource$Type();
export {
  AttributeContext,
  AttributeContext_Api,
  AttributeContext_Auth,
  AttributeContext_Peer,
  AttributeContext_Request,
  AttributeContext_Resource,
  AttributeContext_Response
};
//# sourceMappingURL=attribute_context.js.map