import { ServiceType } from "@protobuf-ts/runtime-rpc";
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 { TransactionFormat } from "./transaction_filter.js";
import { TransactionTree } from "./transaction.js";
import { TopologyTransaction } from "./topology_transaction.js";
import { OffsetCheckpoint } from "./offset_checkpoint.js";
import { Reassignment } from "./reassignment.js";
import { Transaction } from "./transaction.js";
import { UpdateFormat } from "./transaction_filter.js";
import { TransactionFilter } from "./transaction_filter.js";
class GetUpdatesRequest$Type extends MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.GetUpdatesRequest", [
      {
        no: 1,
        name: "begin_exclusive",
        kind: "scalar",
        T: 3,
        L: 0
      },
      {
        no: 2,
        name: "end_inclusive",
        kind: "scalar",
        opt: true,
        T: 3,
        L: 0
      },
      {
        no: 3,
        name: "filter",
        kind: "message",
        T: () => TransactionFilter
      },
      {
        no: 4,
        name: "verbose",
        kind: "scalar",
        T: 8
      },
      {
        no: 5,
        name: "update_format",
        kind: "message",
        T: () => UpdateFormat
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.beginExclusive = 0n;
    message.verbose = false;
    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 begin_exclusive */
        1:
          message.beginExclusive = reader.int64().toBigInt();
          break;
        case /* optional int64 end_inclusive */
        2:
          message.endInclusive = reader.int64().toBigInt();
          break;
        case /* com.daml.ledger.api.v2.TransactionFilter filter = 3 [deprecated = true] */
        3:
          message.filter = TransactionFilter.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.filter
          );
          break;
        case /* bool verbose = 4 [deprecated = true] */
        4:
          message.verbose = reader.bool();
          break;
        case /* com.daml.ledger.api.v2.UpdateFormat update_format */
        5:
          message.updateFormat = UpdateFormat.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.updateFormat
          );
          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.beginExclusive !== 0n)
      writer.tag(1, WireType.Varint).int64(message.beginExclusive);
    if (message.endInclusive !== void 0)
      writer.tag(2, WireType.Varint).int64(message.endInclusive);
    if (message.filter)
      TransactionFilter.internalBinaryWrite(
        message.filter,
        writer.tag(3, WireType.LengthDelimited).fork(),
        options
      ).join();
    if (message.verbose !== false)
      writer.tag(4, WireType.Varint).bool(message.verbose);
    if (message.updateFormat)
      UpdateFormat.internalBinaryWrite(
        message.updateFormat,
        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 GetUpdatesRequest = new GetUpdatesRequest$Type();
class GetUpdatesResponse$Type extends MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.GetUpdatesResponse", [
      {
        no: 1,
        name: "transaction",
        kind: "message",
        oneof: "update",
        T: () => Transaction
      },
      {
        no: 2,
        name: "reassignment",
        kind: "message",
        oneof: "update",
        T: () => Reassignment
      },
      {
        no: 3,
        name: "offset_checkpoint",
        kind: "message",
        oneof: "update",
        T: () => OffsetCheckpoint
      },
      {
        no: 4,
        name: "topology_transaction",
        kind: "message",
        oneof: "update",
        T: () => TopologyTransaction
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.update = { oneofKind: void 0 };
    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 /* com.daml.ledger.api.v2.Transaction transaction */
        1:
          message.update = {
            oneofKind: "transaction",
            transaction: Transaction.internalBinaryRead(
              reader,
              reader.uint32(),
              options,
              message.update.transaction
            )
          };
          break;
        case /* com.daml.ledger.api.v2.Reassignment reassignment */
        2:
          message.update = {
            oneofKind: "reassignment",
            reassignment: Reassignment.internalBinaryRead(
              reader,
              reader.uint32(),
              options,
              message.update.reassignment
            )
          };
          break;
        case /* com.daml.ledger.api.v2.OffsetCheckpoint offset_checkpoint */
        3:
          message.update = {
            oneofKind: "offsetCheckpoint",
            offsetCheckpoint: OffsetCheckpoint.internalBinaryRead(
              reader,
              reader.uint32(),
              options,
              message.update.offsetCheckpoint
            )
          };
          break;
        case /* com.daml.ledger.api.v2.TopologyTransaction topology_transaction */
        4:
          message.update = {
            oneofKind: "topologyTransaction",
            topologyTransaction: TopologyTransaction.internalBinaryRead(
              reader,
              reader.uint32(),
              options,
              message.update.topologyTransaction
            )
          };
          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.update.oneofKind === "transaction")
      Transaction.internalBinaryWrite(
        message.update.transaction,
        writer.tag(1, WireType.LengthDelimited).fork(),
        options
      ).join();
    if (message.update.oneofKind === "reassignment")
      Reassignment.internalBinaryWrite(
        message.update.reassignment,
        writer.tag(2, WireType.LengthDelimited).fork(),
        options
      ).join();
    if (message.update.oneofKind === "offsetCheckpoint")
      OffsetCheckpoint.internalBinaryWrite(
        message.update.offsetCheckpoint,
        writer.tag(3, WireType.LengthDelimited).fork(),
        options
      ).join();
    if (message.update.oneofKind === "topologyTransaction")
      TopologyTransaction.internalBinaryWrite(
        message.update.topologyTransaction,
        writer.tag(4, WireType.LengthDelimited).fork(),
        options
      ).join();
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const GetUpdatesResponse = new GetUpdatesResponse$Type();
class GetUpdateTreesResponse$Type extends MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.GetUpdateTreesResponse", [
      {
        no: 1,
        name: "transaction_tree",
        kind: "message",
        oneof: "update",
        T: () => TransactionTree
      },
      {
        no: 2,
        name: "reassignment",
        kind: "message",
        oneof: "update",
        T: () => Reassignment
      },
      {
        no: 3,
        name: "offset_checkpoint",
        kind: "message",
        oneof: "update",
        T: () => OffsetCheckpoint
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.update = { oneofKind: void 0 };
    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 /* com.daml.ledger.api.v2.TransactionTree transaction_tree */
        1:
          message.update = {
            oneofKind: "transactionTree",
            transactionTree: TransactionTree.internalBinaryRead(
              reader,
              reader.uint32(),
              options,
              message.update.transactionTree
            )
          };
          break;
        case /* com.daml.ledger.api.v2.Reassignment reassignment */
        2:
          message.update = {
            oneofKind: "reassignment",
            reassignment: Reassignment.internalBinaryRead(
              reader,
              reader.uint32(),
              options,
              message.update.reassignment
            )
          };
          break;
        case /* com.daml.ledger.api.v2.OffsetCheckpoint offset_checkpoint */
        3:
          message.update = {
            oneofKind: "offsetCheckpoint",
            offsetCheckpoint: OffsetCheckpoint.internalBinaryRead(
              reader,
              reader.uint32(),
              options,
              message.update.offsetCheckpoint
            )
          };
          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.update.oneofKind === "transactionTree")
      TransactionTree.internalBinaryWrite(
        message.update.transactionTree,
        writer.tag(1, WireType.LengthDelimited).fork(),
        options
      ).join();
    if (message.update.oneofKind === "reassignment")
      Reassignment.internalBinaryWrite(
        message.update.reassignment,
        writer.tag(2, WireType.LengthDelimited).fork(),
        options
      ).join();
    if (message.update.oneofKind === "offsetCheckpoint")
      OffsetCheckpoint.internalBinaryWrite(
        message.update.offsetCheckpoint,
        writer.tag(3, WireType.LengthDelimited).fork(),
        options
      ).join();
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const GetUpdateTreesResponse = new GetUpdateTreesResponse$Type();
class GetTransactionByOffsetRequest$Type extends MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.GetTransactionByOffsetRequest", [
      {
        no: 1,
        name: "offset",
        kind: "scalar",
        T: 3,
        L: 0
      },
      {
        no: 2,
        name: "requesting_parties",
        kind: "scalar",
        repeat: 2,
        T: 9
      },
      {
        no: 3,
        name: "transaction_format",
        kind: "message",
        T: () => TransactionFormat
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.offset = 0n;
    message.requestingParties = [];
    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 offset */
        1:
          message.offset = reader.int64().toBigInt();
          break;
        case /* repeated string requesting_parties */
        2:
          message.requestingParties.push(reader.string());
          break;
        case /* com.daml.ledger.api.v2.TransactionFormat transaction_format */
        3:
          message.transactionFormat = TransactionFormat.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.transactionFormat
          );
          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.offset !== 0n)
      writer.tag(1, WireType.Varint).int64(message.offset);
    for (let i = 0; i < message.requestingParties.length; i++)
      writer.tag(2, WireType.LengthDelimited).string(message.requestingParties[i]);
    if (message.transactionFormat)
      TransactionFormat.internalBinaryWrite(
        message.transactionFormat,
        writer.tag(3, WireType.LengthDelimited).fork(),
        options
      ).join();
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const GetTransactionByOffsetRequest = new GetTransactionByOffsetRequest$Type();
class GetTransactionByIdRequest$Type extends MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.GetTransactionByIdRequest", [
      {
        no: 1,
        name: "update_id",
        kind: "scalar",
        T: 9
      },
      {
        no: 2,
        name: "requesting_parties",
        kind: "scalar",
        repeat: 2,
        T: 9
      },
      {
        no: 3,
        name: "transaction_format",
        kind: "message",
        T: () => TransactionFormat
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.updateId = "";
    message.requestingParties = [];
    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 update_id */
        1:
          message.updateId = reader.string();
          break;
        case /* repeated string requesting_parties */
        2:
          message.requestingParties.push(reader.string());
          break;
        case /* com.daml.ledger.api.v2.TransactionFormat transaction_format */
        3:
          message.transactionFormat = TransactionFormat.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.transactionFormat
          );
          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.updateId !== "")
      writer.tag(1, WireType.LengthDelimited).string(message.updateId);
    for (let i = 0; i < message.requestingParties.length; i++)
      writer.tag(2, WireType.LengthDelimited).string(message.requestingParties[i]);
    if (message.transactionFormat)
      TransactionFormat.internalBinaryWrite(
        message.transactionFormat,
        writer.tag(3, WireType.LengthDelimited).fork(),
        options
      ).join();
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const GetTransactionByIdRequest = new GetTransactionByIdRequest$Type();
class GetTransactionTreeResponse$Type extends MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.GetTransactionTreeResponse", [
      {
        no: 1,
        name: "transaction",
        kind: "message",
        T: () => TransactionTree
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    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 /* com.daml.ledger.api.v2.TransactionTree transaction */
        1:
          message.transaction = TransactionTree.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.transaction
          );
          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.transaction)
      TransactionTree.internalBinaryWrite(
        message.transaction,
        writer.tag(1, WireType.LengthDelimited).fork(),
        options
      ).join();
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const GetTransactionTreeResponse = new GetTransactionTreeResponse$Type();
class GetTransactionResponse$Type extends MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.GetTransactionResponse", [
      {
        no: 1,
        name: "transaction",
        kind: "message",
        T: () => Transaction
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    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 /* com.daml.ledger.api.v2.Transaction transaction */
        1:
          message.transaction = Transaction.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.transaction
          );
          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.transaction)
      Transaction.internalBinaryWrite(
        message.transaction,
        writer.tag(1, WireType.LengthDelimited).fork(),
        options
      ).join();
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const GetTransactionResponse = new GetTransactionResponse$Type();
class GetUpdateByOffsetRequest$Type extends MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.GetUpdateByOffsetRequest", [
      {
        no: 1,
        name: "offset",
        kind: "scalar",
        T: 3,
        L: 0
      },
      {
        no: 2,
        name: "update_format",
        kind: "message",
        T: () => UpdateFormat
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.offset = 0n;
    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 offset */
        1:
          message.offset = reader.int64().toBigInt();
          break;
        case /* com.daml.ledger.api.v2.UpdateFormat update_format */
        2:
          message.updateFormat = UpdateFormat.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.updateFormat
          );
          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.offset !== 0n)
      writer.tag(1, WireType.Varint).int64(message.offset);
    if (message.updateFormat)
      UpdateFormat.internalBinaryWrite(
        message.updateFormat,
        writer.tag(2, WireType.LengthDelimited).fork(),
        options
      ).join();
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const GetUpdateByOffsetRequest = new GetUpdateByOffsetRequest$Type();
class GetUpdateByIdRequest$Type extends MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.GetUpdateByIdRequest", [
      {
        no: 1,
        name: "update_id",
        kind: "scalar",
        T: 9
      },
      {
        no: 2,
        name: "update_format",
        kind: "message",
        T: () => UpdateFormat
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.updateId = "";
    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 update_id */
        1:
          message.updateId = reader.string();
          break;
        case /* com.daml.ledger.api.v2.UpdateFormat update_format */
        2:
          message.updateFormat = UpdateFormat.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.updateFormat
          );
          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.updateId !== "")
      writer.tag(1, WireType.LengthDelimited).string(message.updateId);
    if (message.updateFormat)
      UpdateFormat.internalBinaryWrite(
        message.updateFormat,
        writer.tag(2, WireType.LengthDelimited).fork(),
        options
      ).join();
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const GetUpdateByIdRequest = new GetUpdateByIdRequest$Type();
class GetUpdateResponse$Type extends MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.GetUpdateResponse", [
      {
        no: 1,
        name: "transaction",
        kind: "message",
        oneof: "update",
        T: () => Transaction
      },
      {
        no: 2,
        name: "reassignment",
        kind: "message",
        oneof: "update",
        T: () => Reassignment
      },
      {
        no: 3,
        name: "topology_transaction",
        kind: "message",
        oneof: "update",
        T: () => TopologyTransaction
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.update = { oneofKind: void 0 };
    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 /* com.daml.ledger.api.v2.Transaction transaction */
        1:
          message.update = {
            oneofKind: "transaction",
            transaction: Transaction.internalBinaryRead(
              reader,
              reader.uint32(),
              options,
              message.update.transaction
            )
          };
          break;
        case /* com.daml.ledger.api.v2.Reassignment reassignment */
        2:
          message.update = {
            oneofKind: "reassignment",
            reassignment: Reassignment.internalBinaryRead(
              reader,
              reader.uint32(),
              options,
              message.update.reassignment
            )
          };
          break;
        case /* com.daml.ledger.api.v2.TopologyTransaction topology_transaction */
        3:
          message.update = {
            oneofKind: "topologyTransaction",
            topologyTransaction: TopologyTransaction.internalBinaryRead(
              reader,
              reader.uint32(),
              options,
              message.update.topologyTransaction
            )
          };
          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.update.oneofKind === "transaction")
      Transaction.internalBinaryWrite(
        message.update.transaction,
        writer.tag(1, WireType.LengthDelimited).fork(),
        options
      ).join();
    if (message.update.oneofKind === "reassignment")
      Reassignment.internalBinaryWrite(
        message.update.reassignment,
        writer.tag(2, WireType.LengthDelimited).fork(),
        options
      ).join();
    if (message.update.oneofKind === "topologyTransaction")
      TopologyTransaction.internalBinaryWrite(
        message.update.topologyTransaction,
        writer.tag(3, WireType.LengthDelimited).fork(),
        options
      ).join();
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const GetUpdateResponse = new GetUpdateResponse$Type();
const UpdateService = new ServiceType(
  "com.daml.ledger.api.v2.UpdateService",
  [
    {
      name: "GetUpdates",
      serverStreaming: true,
      options: {},
      I: GetUpdatesRequest,
      O: GetUpdatesResponse
    },
    {
      name: "GetUpdateTrees",
      serverStreaming: true,
      options: {},
      I: GetUpdatesRequest,
      O: GetUpdateTreesResponse
    },
    {
      name: "GetTransactionTreeByOffset",
      options: {},
      I: GetTransactionByOffsetRequest,
      O: GetTransactionTreeResponse
    },
    {
      name: "GetTransactionTreeById",
      options: {},
      I: GetTransactionByIdRequest,
      O: GetTransactionTreeResponse
    },
    {
      name: "GetTransactionByOffset",
      options: {},
      I: GetTransactionByOffsetRequest,
      O: GetTransactionResponse
    },
    {
      name: "GetTransactionById",
      options: {},
      I: GetTransactionByIdRequest,
      O: GetTransactionResponse
    },
    {
      name: "GetUpdateByOffset",
      options: {},
      I: GetUpdateByOffsetRequest,
      O: GetUpdateResponse
    },
    {
      name: "GetUpdateById",
      options: {},
      I: GetUpdateByIdRequest,
      O: GetUpdateResponse
    }
  ]
);
export {
  GetTransactionByIdRequest,
  GetTransactionByOffsetRequest,
  GetTransactionResponse,
  GetTransactionTreeResponse,
  GetUpdateByIdRequest,
  GetUpdateByOffsetRequest,
  GetUpdateResponse,
  GetUpdateTreesResponse,
  GetUpdatesRequest,
  GetUpdatesResponse,
  UpdateService
};
//# sourceMappingURL=update_service.js.map