"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var command_service_exports = {};
__export(command_service_exports, {
  CommandService: () => CommandService,
  SubmitAndWaitForReassignmentRequest: () => SubmitAndWaitForReassignmentRequest,
  SubmitAndWaitForReassignmentResponse: () => SubmitAndWaitForReassignmentResponse,
  SubmitAndWaitForTransactionRequest: () => SubmitAndWaitForTransactionRequest,
  SubmitAndWaitForTransactionResponse: () => SubmitAndWaitForTransactionResponse,
  SubmitAndWaitForTransactionTreeResponse: () => SubmitAndWaitForTransactionTreeResponse,
  SubmitAndWaitRequest: () => SubmitAndWaitRequest,
  SubmitAndWaitResponse: () => SubmitAndWaitResponse
});
module.exports = __toCommonJS(command_service_exports);
var import_runtime_rpc = require("@protobuf-ts/runtime-rpc");
var import_runtime = require("@protobuf-ts/runtime");
var import_runtime2 = require("@protobuf-ts/runtime");
var import_runtime3 = require("@protobuf-ts/runtime");
var import_runtime4 = require("@protobuf-ts/runtime");
var import_reassignment = require("./reassignment.cjs");
var import_transaction_filter = require("./transaction_filter.cjs");
var import_reassignment_commands = require("./reassignment_commands.cjs");
var import_transaction = require("./transaction.cjs");
var import_transaction2 = require("./transaction.cjs");
var import_transaction_filter2 = require("./transaction_filter.cjs");
var import_commands = require("./commands.cjs");
class SubmitAndWaitRequest$Type extends import_runtime4.MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.SubmitAndWaitRequest", [
      { no: 1, name: "commands", kind: "message", T: () => import_commands.Commands }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    if (value !== void 0)
      (0, import_runtime3.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.Commands commands */
        1:
          message.commands = import_commands.Commands.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.commands
          );
          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 ? import_runtime2.UnknownFieldHandler.onRead : u)(
              this.typeName,
              message,
              fieldNo,
              wireType,
              d
            );
      }
    }
    return message;
  }
  internalBinaryWrite(message, writer, options) {
    if (message.commands)
      import_commands.Commands.internalBinaryWrite(
        message.commands,
        writer.tag(1, import_runtime.WireType.LengthDelimited).fork(),
        options
      ).join();
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const SubmitAndWaitRequest = new SubmitAndWaitRequest$Type();
class SubmitAndWaitForTransactionRequest$Type extends import_runtime4.MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.SubmitAndWaitForTransactionRequest", [
      { no: 1, name: "commands", kind: "message", T: () => import_commands.Commands },
      {
        no: 2,
        name: "transaction_format",
        kind: "message",
        T: () => import_transaction_filter2.TransactionFormat
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    if (value !== void 0)
      (0, import_runtime3.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.Commands commands */
        1:
          message.commands = import_commands.Commands.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.commands
          );
          break;
        case /* com.daml.ledger.api.v2.TransactionFormat transaction_format */
        2:
          message.transactionFormat = import_transaction_filter2.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 ? import_runtime2.UnknownFieldHandler.onRead : u)(
              this.typeName,
              message,
              fieldNo,
              wireType,
              d
            );
      }
    }
    return message;
  }
  internalBinaryWrite(message, writer, options) {
    if (message.commands)
      import_commands.Commands.internalBinaryWrite(
        message.commands,
        writer.tag(1, import_runtime.WireType.LengthDelimited).fork(),
        options
      ).join();
    if (message.transactionFormat)
      import_transaction_filter2.TransactionFormat.internalBinaryWrite(
        message.transactionFormat,
        writer.tag(2, import_runtime.WireType.LengthDelimited).fork(),
        options
      ).join();
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const SubmitAndWaitForTransactionRequest = new SubmitAndWaitForTransactionRequest$Type();
class SubmitAndWaitResponse$Type extends import_runtime4.MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.SubmitAndWaitResponse", [
      {
        no: 1,
        name: "update_id",
        kind: "scalar",
        T: 9
      },
      {
        no: 2,
        name: "completion_offset",
        kind: "scalar",
        T: 3,
        L: 0
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.updateId = "";
    message.completionOffset = 0n;
    if (value !== void 0)
      (0, import_runtime3.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 /* int64 completion_offset */
        2:
          message.completionOffset = reader.int64().toBigInt();
          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 ? import_runtime2.UnknownFieldHandler.onRead : u)(
              this.typeName,
              message,
              fieldNo,
              wireType,
              d
            );
      }
    }
    return message;
  }
  internalBinaryWrite(message, writer, options) {
    if (message.updateId !== "")
      writer.tag(1, import_runtime.WireType.LengthDelimited).string(message.updateId);
    if (message.completionOffset !== 0n)
      writer.tag(2, import_runtime.WireType.Varint).int64(message.completionOffset);
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const SubmitAndWaitResponse = new SubmitAndWaitResponse$Type();
class SubmitAndWaitForTransactionResponse$Type extends import_runtime4.MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.SubmitAndWaitForTransactionResponse", [
      {
        no: 1,
        name: "transaction",
        kind: "message",
        T: () => import_transaction2.Transaction
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    if (value !== void 0)
      (0, import_runtime3.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 = import_transaction2.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 ? import_runtime2.UnknownFieldHandler.onRead : u)(
              this.typeName,
              message,
              fieldNo,
              wireType,
              d
            );
      }
    }
    return message;
  }
  internalBinaryWrite(message, writer, options) {
    if (message.transaction)
      import_transaction2.Transaction.internalBinaryWrite(
        message.transaction,
        writer.tag(1, import_runtime.WireType.LengthDelimited).fork(),
        options
      ).join();
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const SubmitAndWaitForTransactionResponse = new SubmitAndWaitForTransactionResponse$Type();
class SubmitAndWaitForTransactionTreeResponse$Type extends import_runtime4.MessageType {
  constructor() {
    super(
      "com.daml.ledger.api.v2.SubmitAndWaitForTransactionTreeResponse",
      [
        {
          no: 1,
          name: "transaction",
          kind: "message",
          T: () => import_transaction.TransactionTree
        }
      ]
    );
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    if (value !== void 0)
      (0, import_runtime3.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 = import_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 ? import_runtime2.UnknownFieldHandler.onRead : u)(
              this.typeName,
              message,
              fieldNo,
              wireType,
              d
            );
      }
    }
    return message;
  }
  internalBinaryWrite(message, writer, options) {
    if (message.transaction)
      import_transaction.TransactionTree.internalBinaryWrite(
        message.transaction,
        writer.tag(1, import_runtime.WireType.LengthDelimited).fork(),
        options
      ).join();
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const SubmitAndWaitForTransactionTreeResponse = new SubmitAndWaitForTransactionTreeResponse$Type();
class SubmitAndWaitForReassignmentRequest$Type extends import_runtime4.MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.SubmitAndWaitForReassignmentRequest", [
      {
        no: 1,
        name: "reassignment_commands",
        kind: "message",
        T: () => import_reassignment_commands.ReassignmentCommands
      },
      {
        no: 2,
        name: "event_format",
        kind: "message",
        T: () => import_transaction_filter.EventFormat
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    if (value !== void 0)
      (0, import_runtime3.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.ReassignmentCommands reassignment_commands */
        1:
          message.reassignmentCommands = import_reassignment_commands.ReassignmentCommands.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.reassignmentCommands
          );
          break;
        case /* com.daml.ledger.api.v2.EventFormat event_format */
        2:
          message.eventFormat = import_transaction_filter.EventFormat.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.eventFormat
          );
          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 ? import_runtime2.UnknownFieldHandler.onRead : u)(
              this.typeName,
              message,
              fieldNo,
              wireType,
              d
            );
      }
    }
    return message;
  }
  internalBinaryWrite(message, writer, options) {
    if (message.reassignmentCommands)
      import_reassignment_commands.ReassignmentCommands.internalBinaryWrite(
        message.reassignmentCommands,
        writer.tag(1, import_runtime.WireType.LengthDelimited).fork(),
        options
      ).join();
    if (message.eventFormat)
      import_transaction_filter.EventFormat.internalBinaryWrite(
        message.eventFormat,
        writer.tag(2, import_runtime.WireType.LengthDelimited).fork(),
        options
      ).join();
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const SubmitAndWaitForReassignmentRequest = new SubmitAndWaitForReassignmentRequest$Type();
class SubmitAndWaitForReassignmentResponse$Type extends import_runtime4.MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.SubmitAndWaitForReassignmentResponse", [
      {
        no: 1,
        name: "reassignment",
        kind: "message",
        T: () => import_reassignment.Reassignment
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    if (value !== void 0)
      (0, import_runtime3.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.Reassignment reassignment */
        1:
          message.reassignment = import_reassignment.Reassignment.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.reassignment
          );
          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 ? import_runtime2.UnknownFieldHandler.onRead : u)(
              this.typeName,
              message,
              fieldNo,
              wireType,
              d
            );
      }
    }
    return message;
  }
  internalBinaryWrite(message, writer, options) {
    if (message.reassignment)
      import_reassignment.Reassignment.internalBinaryWrite(
        message.reassignment,
        writer.tag(1, import_runtime.WireType.LengthDelimited).fork(),
        options
      ).join();
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const SubmitAndWaitForReassignmentResponse = new SubmitAndWaitForReassignmentResponse$Type();
const CommandService = new import_runtime_rpc.ServiceType(
  "com.daml.ledger.api.v2.CommandService",
  [
    {
      name: "SubmitAndWait",
      options: {},
      I: SubmitAndWaitRequest,
      O: SubmitAndWaitResponse
    },
    {
      name: "SubmitAndWaitForTransaction",
      options: {},
      I: SubmitAndWaitForTransactionRequest,
      O: SubmitAndWaitForTransactionResponse
    },
    {
      name: "SubmitAndWaitForTransactionTree",
      options: {},
      I: SubmitAndWaitRequest,
      O: SubmitAndWaitForTransactionTreeResponse
    },
    {
      name: "SubmitAndWaitForReassignment",
      options: {},
      I: SubmitAndWaitForReassignmentRequest,
      O: SubmitAndWaitForReassignmentResponse
    }
  ]
);
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  CommandService,
  SubmitAndWaitForReassignmentRequest,
  SubmitAndWaitForReassignmentResponse,
  SubmitAndWaitForTransactionRequest,
  SubmitAndWaitForTransactionResponse,
  SubmitAndWaitForTransactionTreeResponse,
  SubmitAndWaitRequest,
  SubmitAndWaitResponse
});
//# sourceMappingURL=command_service.cjs.map