"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 reassignment_exports = {};
__export(reassignment_exports, {
  AssignedEvent: () => AssignedEvent,
  Reassignment: () => Reassignment,
  ReassignmentEvent: () => ReassignmentEvent,
  UnassignedEvent: () => UnassignedEvent
});
module.exports = __toCommonJS(reassignment_exports);
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_event = require("./event.cjs");
var import_value = require("./value.cjs");
var import_timestamp = require("../../../../../google/protobuf/timestamp.cjs");
var import_trace_context = require("./trace_context.cjs");
class Reassignment$Type extends import_runtime4.MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.Reassignment", [
      {
        no: 1,
        name: "update_id",
        kind: "scalar",
        T: 9
      },
      {
        no: 2,
        name: "command_id",
        kind: "scalar",
        T: 9
      },
      {
        no: 3,
        name: "workflow_id",
        kind: "scalar",
        T: 9
      },
      {
        no: 4,
        name: "offset",
        kind: "scalar",
        T: 3,
        L: 0
      },
      {
        no: 5,
        name: "events",
        kind: "message",
        repeat: 2,
        T: () => ReassignmentEvent
      },
      {
        no: 6,
        name: "trace_context",
        kind: "message",
        T: () => import_trace_context.TraceContext
      },
      { no: 7, name: "record_time", kind: "message", T: () => import_timestamp.Timestamp }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.updateId = "";
    message.commandId = "";
    message.workflowId = "";
    message.offset = 0n;
    message.events = [];
    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 /* string command_id */
        2:
          message.commandId = reader.string();
          break;
        case /* string workflow_id */
        3:
          message.workflowId = reader.string();
          break;
        case /* int64 offset */
        4:
          message.offset = reader.int64().toBigInt();
          break;
        case /* repeated com.daml.ledger.api.v2.ReassignmentEvent events */
        5:
          message.events.push(
            ReassignmentEvent.internalBinaryRead(
              reader,
              reader.uint32(),
              options
            )
          );
          break;
        case /* com.daml.ledger.api.v2.TraceContext trace_context */
        6:
          message.traceContext = import_trace_context.TraceContext.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.traceContext
          );
          break;
        case /* google.protobuf.Timestamp record_time */
        7:
          message.recordTime = import_timestamp.Timestamp.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.recordTime
          );
          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.commandId !== "")
      writer.tag(2, import_runtime.WireType.LengthDelimited).string(message.commandId);
    if (message.workflowId !== "")
      writer.tag(3, import_runtime.WireType.LengthDelimited).string(message.workflowId);
    if (message.offset !== 0n)
      writer.tag(4, import_runtime.WireType.Varint).int64(message.offset);
    for (let i = 0; i < message.events.length; i++)
      ReassignmentEvent.internalBinaryWrite(
        message.events[i],
        writer.tag(5, import_runtime.WireType.LengthDelimited).fork(),
        options
      ).join();
    if (message.traceContext)
      import_trace_context.TraceContext.internalBinaryWrite(
        message.traceContext,
        writer.tag(6, import_runtime.WireType.LengthDelimited).fork(),
        options
      ).join();
    if (message.recordTime)
      import_timestamp.Timestamp.internalBinaryWrite(
        message.recordTime,
        writer.tag(7, 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 Reassignment = new Reassignment$Type();
class ReassignmentEvent$Type extends import_runtime4.MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.ReassignmentEvent", [
      {
        no: 1,
        name: "unassigned",
        kind: "message",
        oneof: "event",
        T: () => UnassignedEvent
      },
      {
        no: 2,
        name: "assigned",
        kind: "message",
        oneof: "event",
        T: () => AssignedEvent
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.event = { oneofKind: void 0 };
    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.UnassignedEvent unassigned */
        1:
          message.event = {
            oneofKind: "unassigned",
            unassigned: UnassignedEvent.internalBinaryRead(
              reader,
              reader.uint32(),
              options,
              message.event.unassigned
            )
          };
          break;
        case /* com.daml.ledger.api.v2.AssignedEvent assigned */
        2:
          message.event = {
            oneofKind: "assigned",
            assigned: AssignedEvent.internalBinaryRead(
              reader,
              reader.uint32(),
              options,
              message.event.assigned
            )
          };
          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.event.oneofKind === "unassigned")
      UnassignedEvent.internalBinaryWrite(
        message.event.unassigned,
        writer.tag(1, import_runtime.WireType.LengthDelimited).fork(),
        options
      ).join();
    if (message.event.oneofKind === "assigned")
      AssignedEvent.internalBinaryWrite(
        message.event.assigned,
        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 ReassignmentEvent = new ReassignmentEvent$Type();
class UnassignedEvent$Type extends import_runtime4.MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.UnassignedEvent", [
      {
        no: 1,
        name: "unassign_id",
        kind: "scalar",
        T: 9
      },
      {
        no: 2,
        name: "contract_id",
        kind: "scalar",
        T: 9
      },
      {
        no: 3,
        name: "template_id",
        kind: "message",
        T: () => import_value.Identifier
      },
      {
        no: 4,
        name: "source",
        kind: "scalar",
        T: 9
      },
      {
        no: 5,
        name: "target",
        kind: "scalar",
        T: 9
      },
      {
        no: 6,
        name: "submitter",
        kind: "scalar",
        T: 9
      },
      {
        no: 7,
        name: "reassignment_counter",
        kind: "scalar",
        T: 4,
        L: 0
      },
      {
        no: 8,
        name: "assignment_exclusivity",
        kind: "message",
        T: () => import_timestamp.Timestamp
      },
      {
        no: 9,
        name: "witness_parties",
        kind: "scalar",
        repeat: 2,
        T: 9
      },
      {
        no: 10,
        name: "package_name",
        kind: "scalar",
        T: 9
      },
      {
        no: 11,
        name: "offset",
        kind: "scalar",
        T: 3,
        L: 0
      },
      {
        no: 12,
        name: "node_id",
        kind: "scalar",
        T: 5
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.unassignId = "";
    message.contractId = "";
    message.source = "";
    message.target = "";
    message.submitter = "";
    message.reassignmentCounter = 0n;
    message.witnessParties = [];
    message.packageName = "";
    message.offset = 0n;
    message.nodeId = 0;
    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 unassign_id */
        1:
          message.unassignId = reader.string();
          break;
        case /* string contract_id */
        2:
          message.contractId = reader.string();
          break;
        case /* com.daml.ledger.api.v2.Identifier template_id */
        3:
          message.templateId = import_value.Identifier.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.templateId
          );
          break;
        case /* string source */
        4:
          message.source = reader.string();
          break;
        case /* string target */
        5:
          message.target = reader.string();
          break;
        case /* string submitter */
        6:
          message.submitter = reader.string();
          break;
        case /* uint64 reassignment_counter */
        7:
          message.reassignmentCounter = reader.uint64().toBigInt();
          break;
        case /* google.protobuf.Timestamp assignment_exclusivity */
        8:
          message.assignmentExclusivity = import_timestamp.Timestamp.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.assignmentExclusivity
          );
          break;
        case /* repeated string witness_parties */
        9:
          message.witnessParties.push(reader.string());
          break;
        case /* string package_name */
        10:
          message.packageName = reader.string();
          break;
        case /* int64 offset */
        11:
          message.offset = reader.int64().toBigInt();
          break;
        case /* int32 node_id */
        12:
          message.nodeId = reader.int32();
          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.unassignId !== "")
      writer.tag(1, import_runtime.WireType.LengthDelimited).string(message.unassignId);
    if (message.contractId !== "")
      writer.tag(2, import_runtime.WireType.LengthDelimited).string(message.contractId);
    if (message.templateId)
      import_value.Identifier.internalBinaryWrite(
        message.templateId,
        writer.tag(3, import_runtime.WireType.LengthDelimited).fork(),
        options
      ).join();
    if (message.source !== "")
      writer.tag(4, import_runtime.WireType.LengthDelimited).string(message.source);
    if (message.target !== "")
      writer.tag(5, import_runtime.WireType.LengthDelimited).string(message.target);
    if (message.submitter !== "")
      writer.tag(6, import_runtime.WireType.LengthDelimited).string(message.submitter);
    if (message.reassignmentCounter !== 0n)
      writer.tag(7, import_runtime.WireType.Varint).uint64(message.reassignmentCounter);
    if (message.assignmentExclusivity)
      import_timestamp.Timestamp.internalBinaryWrite(
        message.assignmentExclusivity,
        writer.tag(8, import_runtime.WireType.LengthDelimited).fork(),
        options
      ).join();
    for (let i = 0; i < message.witnessParties.length; i++)
      writer.tag(9, import_runtime.WireType.LengthDelimited).string(message.witnessParties[i]);
    if (message.packageName !== "")
      writer.tag(10, import_runtime.WireType.LengthDelimited).string(message.packageName);
    if (message.offset !== 0n)
      writer.tag(11, import_runtime.WireType.Varint).int64(message.offset);
    if (message.nodeId !== 0)
      writer.tag(12, import_runtime.WireType.Varint).int32(message.nodeId);
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const UnassignedEvent = new UnassignedEvent$Type();
class AssignedEvent$Type extends import_runtime4.MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.AssignedEvent", [
      {
        no: 1,
        name: "source",
        kind: "scalar",
        T: 9
      },
      {
        no: 2,
        name: "target",
        kind: "scalar",
        T: 9
      },
      {
        no: 3,
        name: "unassign_id",
        kind: "scalar",
        T: 9
      },
      {
        no: 4,
        name: "submitter",
        kind: "scalar",
        T: 9
      },
      {
        no: 5,
        name: "reassignment_counter",
        kind: "scalar",
        T: 4,
        L: 0
      },
      {
        no: 6,
        name: "created_event",
        kind: "message",
        T: () => import_event.CreatedEvent
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.source = "";
    message.target = "";
    message.unassignId = "";
    message.submitter = "";
    message.reassignmentCounter = 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 source */
        1:
          message.source = reader.string();
          break;
        case /* string target */
        2:
          message.target = reader.string();
          break;
        case /* string unassign_id */
        3:
          message.unassignId = reader.string();
          break;
        case /* string submitter */
        4:
          message.submitter = reader.string();
          break;
        case /* uint64 reassignment_counter */
        5:
          message.reassignmentCounter = reader.uint64().toBigInt();
          break;
        case /* com.daml.ledger.api.v2.CreatedEvent created_event */
        6:
          message.createdEvent = import_event.CreatedEvent.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.createdEvent
          );
          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.source !== "")
      writer.tag(1, import_runtime.WireType.LengthDelimited).string(message.source);
    if (message.target !== "")
      writer.tag(2, import_runtime.WireType.LengthDelimited).string(message.target);
    if (message.unassignId !== "")
      writer.tag(3, import_runtime.WireType.LengthDelimited).string(message.unassignId);
    if (message.submitter !== "")
      writer.tag(4, import_runtime.WireType.LengthDelimited).string(message.submitter);
    if (message.reassignmentCounter !== 0n)
      writer.tag(5, import_runtime.WireType.Varint).uint64(message.reassignmentCounter);
    if (message.createdEvent)
      import_event.CreatedEvent.internalBinaryWrite(
        message.createdEvent,
        writer.tag(6, 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 AssignedEvent = new AssignedEvent$Type();
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  AssignedEvent,
  Reassignment,
  ReassignmentEvent,
  UnassignedEvent
});
//# sourceMappingURL=reassignment.cjs.map