"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 package_management_service_exports = {};
__export(package_management_service_exports, {
  ListKnownPackagesRequest: () => ListKnownPackagesRequest,
  ListKnownPackagesResponse: () => ListKnownPackagesResponse,
  PackageDetails: () => PackageDetails,
  PackageManagementService: () => PackageManagementService,
  UploadDarFileRequest: () => UploadDarFileRequest,
  UploadDarFileResponse: () => UploadDarFileResponse,
  ValidateDarFileRequest: () => ValidateDarFileRequest,
  ValidateDarFileResponse: () => ValidateDarFileResponse
});
module.exports = __toCommonJS(package_management_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_timestamp = require("../../../../../../google/protobuf/timestamp.cjs");
class ListKnownPackagesRequest$Type extends import_runtime4.MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.admin.ListKnownPackagesRequest", []);
  }
  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) {
        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) {
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const ListKnownPackagesRequest = new ListKnownPackagesRequest$Type();
class ListKnownPackagesResponse$Type extends import_runtime4.MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.admin.ListKnownPackagesResponse", [
      {
        no: 1,
        name: "package_details",
        kind: "message",
        repeat: 2,
        T: () => PackageDetails
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.packageDetails = [];
    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 /* repeated com.daml.ledger.api.v2.admin.PackageDetails package_details */
        1:
          message.packageDetails.push(
            PackageDetails.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 ? import_runtime2.UnknownFieldHandler.onRead : u)(
              this.typeName,
              message,
              fieldNo,
              wireType,
              d
            );
      }
    }
    return message;
  }
  internalBinaryWrite(message, writer, options) {
    for (let i = 0; i < message.packageDetails.length; i++)
      PackageDetails.internalBinaryWrite(
        message.packageDetails[i],
        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 ListKnownPackagesResponse = new ListKnownPackagesResponse$Type();
class PackageDetails$Type extends import_runtime4.MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.admin.PackageDetails", [
      {
        no: 1,
        name: "package_id",
        kind: "scalar",
        T: 9
      },
      {
        no: 2,
        name: "package_size",
        kind: "scalar",
        T: 4,
        L: 0
      },
      { no: 3, name: "known_since", kind: "message", T: () => import_timestamp.Timestamp },
      {
        no: 4,
        name: "name",
        kind: "scalar",
        T: 9
        /*ScalarType.STRING*/
      },
      {
        no: 5,
        name: "version",
        kind: "scalar",
        T: 9
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.packageId = "";
    message.packageSize = 0n;
    message.name = "";
    message.version = "";
    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 package_id */
        1:
          message.packageId = reader.string();
          break;
        case /* uint64 package_size */
        2:
          message.packageSize = reader.uint64().toBigInt();
          break;
        case /* google.protobuf.Timestamp known_since */
        3:
          message.knownSince = import_timestamp.Timestamp.internalBinaryRead(
            reader,
            reader.uint32(),
            options,
            message.knownSince
          );
          break;
        case /* string name */
        4:
          message.name = reader.string();
          break;
        case /* string version */
        5:
          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 ? import_runtime2.UnknownFieldHandler.onRead : u)(
              this.typeName,
              message,
              fieldNo,
              wireType,
              d
            );
      }
    }
    return message;
  }
  internalBinaryWrite(message, writer, options) {
    if (message.packageId !== "")
      writer.tag(1, import_runtime.WireType.LengthDelimited).string(message.packageId);
    if (message.packageSize !== 0n)
      writer.tag(2, import_runtime.WireType.Varint).uint64(message.packageSize);
    if (message.knownSince)
      import_timestamp.Timestamp.internalBinaryWrite(
        message.knownSince,
        writer.tag(3, import_runtime.WireType.LengthDelimited).fork(),
        options
      ).join();
    if (message.name !== "")
      writer.tag(4, import_runtime.WireType.LengthDelimited).string(message.name);
    if (message.version !== "")
      writer.tag(5, import_runtime.WireType.LengthDelimited).string(message.version);
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const PackageDetails = new PackageDetails$Type();
class UploadDarFileRequest$Type extends import_runtime4.MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.admin.UploadDarFileRequest", [
      {
        no: 1,
        name: "dar_file",
        kind: "scalar",
        T: 12
      },
      {
        no: 2,
        name: "submission_id",
        kind: "scalar",
        T: 9
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.darFile = new Uint8Array(0);
    message.submissionId = "";
    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 /* bytes dar_file */
        1:
          message.darFile = reader.bytes();
          break;
        case /* string submission_id */
        2:
          message.submissionId = 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 ? import_runtime2.UnknownFieldHandler.onRead : u)(
              this.typeName,
              message,
              fieldNo,
              wireType,
              d
            );
      }
    }
    return message;
  }
  internalBinaryWrite(message, writer, options) {
    if (message.darFile.length)
      writer.tag(1, import_runtime.WireType.LengthDelimited).bytes(message.darFile);
    if (message.submissionId !== "")
      writer.tag(2, import_runtime.WireType.LengthDelimited).string(message.submissionId);
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const UploadDarFileRequest = new UploadDarFileRequest$Type();
class UploadDarFileResponse$Type extends import_runtime4.MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.admin.UploadDarFileResponse", []);
  }
  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) {
        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) {
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const UploadDarFileResponse = new UploadDarFileResponse$Type();
class ValidateDarFileRequest$Type extends import_runtime4.MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.admin.ValidateDarFileRequest", [
      {
        no: 1,
        name: "dar_file",
        kind: "scalar",
        T: 12
      },
      {
        no: 2,
        name: "submission_id",
        kind: "scalar",
        T: 9
      }
    ]);
  }
  create(value) {
    const message = globalThis.Object.create(this.messagePrototype);
    message.darFile = new Uint8Array(0);
    message.submissionId = "";
    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 /* bytes dar_file */
        1:
          message.darFile = reader.bytes();
          break;
        case /* string submission_id */
        2:
          message.submissionId = 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 ? import_runtime2.UnknownFieldHandler.onRead : u)(
              this.typeName,
              message,
              fieldNo,
              wireType,
              d
            );
      }
    }
    return message;
  }
  internalBinaryWrite(message, writer, options) {
    if (message.darFile.length)
      writer.tag(1, import_runtime.WireType.LengthDelimited).bytes(message.darFile);
    if (message.submissionId !== "")
      writer.tag(2, import_runtime.WireType.LengthDelimited).string(message.submissionId);
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const ValidateDarFileRequest = new ValidateDarFileRequest$Type();
class ValidateDarFileResponse$Type extends import_runtime4.MessageType {
  constructor() {
    super("com.daml.ledger.api.v2.admin.ValidateDarFileResponse", []);
  }
  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) {
        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) {
    let u = options.writeUnknownFields;
    if (u !== false)
      (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(
        this.typeName,
        message,
        writer
      );
    return writer;
  }
}
const ValidateDarFileResponse = new ValidateDarFileResponse$Type();
const PackageManagementService = new import_runtime_rpc.ServiceType(
  "com.daml.ledger.api.v2.admin.PackageManagementService",
  [
    {
      name: "ListKnownPackages",
      options: {},
      I: ListKnownPackagesRequest,
      O: ListKnownPackagesResponse
    },
    {
      name: "UploadDarFile",
      options: {},
      I: UploadDarFileRequest,
      O: UploadDarFileResponse
    },
    {
      name: "ValidateDarFile",
      options: {},
      I: ValidateDarFileRequest,
      O: ValidateDarFileResponse
    }
  ]
);
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  ListKnownPackagesRequest,
  ListKnownPackagesResponse,
  PackageDetails,
  PackageManagementService,
  UploadDarFileRequest,
  UploadDarFileResponse,
  ValidateDarFileRequest,
  ValidateDarFileResponse
});
//# sourceMappingURL=package_management_service.cjs.map