'use strict';

require('../../utils/types/array.cjs');
require('crypto');
var utils_interfaces = require('../../utils/interfaces.cjs');
require('bs58');
require('multiformats/bases/base58');
require('varint');
require('../../utils/encoding/ss-58.cjs');
var types_statusListCredential_statusListCredentialValue = require('./status-list-credential-value.cjs');
var types_generic_typedEnum = require('../generic/typed-enum.cjs');
require('../generic/typed-bytes.cjs');
require('../generic/typed-string.cjs');
require('../generic/typed-array.cjs');
require('../generic/typed-tuple.cjs');
require('../generic/typed-null.cjs');
require('../generic/typed-number.cjs');
require('../generic/typed-set.cjs');
require('../generic/typed-map.cjs');
require('../generic/typed-struct.cjs');
require('uuid');
require('js-sha256');
var types_generic_withFrom = require('../generic/with-from.cjs');
var vc_statusList2021Credential = require('../../vc/status-list2021-credential.cjs');
var types_statusListCredential_id = require('./id.cjs');
require('../../utils/inheritance.cjs');
require('../../utils/types/object.cjs');
require('../../utils/types/iterable.cjs');
require('../../utils/types/set.cjs');
require('../../utils/assert.cjs');
require('../../utils/error.cjs');
require('blake2b');
require('../../utils/types/bytes.cjs');
require('../../utils/types/string.cjs');
require('../generic/with-base.cjs');
require('../generic/with-catch-null.cjs');
require('../generic/with-eq.cjs');
require('../generic/any-of.cjs');
require('../generic/with-from-json-bytes.cjs');
require('../generic/create-placeholder.cjs');
require('@digitalcredentials/vc-status-list');
require('pako');
require('../../vc/verifiable-credential.cjs');
require('../../vc/helpers.cjs');
require('jsonld');
require('@transmute/json-web-signature');
require('../../vc/document-loader.cjs');
require('../../vc/contexts.cjs');
require('../../vc/contexts/vc-examples-v1.cjs');
require('../../vc/contexts/security_context.cjs');
require('../../vc/contexts/status-list-21.cjs');
require('../../vc/contexts/private-status-list-21.cjs');
require('../../utils/json-fetch.cjs');
require('../../vc/crypto/Bls12381BBDT16KeyPairDock2024.cjs');
require('@docknetwork/crypto-wasm-ts');
require('../../vc/crypto/constants.cjs');
require('../../vc/crypto/common/DockCryptoKeyPair.cjs');
require('../../vc/crypto/Bls12381BBDT16MACDock2024.cjs');
require('@docknetwork/crypto-wasm-ts/lib/index.js');
require('../../vc/crypto/common/DockCryptoSignature.cjs');
require('jsonld-signatures');
require('json-stringify-deterministic');
require('semver/preload.js');
require('../../vc/crypto/common/CustomLinkedDataSignature.cjs');
require('base64url');
require('../did/document/verification-method-ref.cjs');
require('../generic/with-qualifier.cjs');
require('../generic/utils.cjs');
require('../generic/typed-bytes-array.cjs');
require('../did/onchain/typed-did/index.cjs');
require('../did/onchain/typed-did/did-method-key/did-method-key-public-key.cjs');
require('../../utils/encoding/base-58-btc.cjs');
require('../generic/sized.cjs');
require('../../utils/types/number.cjs');
require('../public-keys/public-key.cjs');
require('../public-keys/public-key-x25519-value.cjs');
require('../public-keys/public-key-ed25519-value.cjs');
require('../public-keys/public-key-secp256k1-value.cjs');
require('../public-keys/public-key-sr25519-value.cjs');
require('../did/onchain/constants.cjs');
require('../did/onchain/typed-did/signature.cjs');
require('../did/onchain/typed-did/did-method-key/did-method-key-signature.cjs');
require('../signatures/signature-value.cjs');
require('../signatures/signature-ed25519-value.cjs');
require('../signatures/signature-secp256k1-value.cjs');
require('../signatures/signature.cjs');
require('../signatures/signature-sr25519-value.cjs');
require('../did/onchain/typed-did/dock-did-value.cjs');
require('../generic/typed-uuid.cjs');
require('../did/onchain/typed-did/cheqd-did.cjs');
require('../../vc/jws.cjs');
require('../../vc/crypto/Bls12381BBDT16MACProofDock2024.cjs');
require('../../vc/crypto/common/DockCryptoSignatureProof.cjs');
require('../../vc/crypto/Bls12381BBSKeyPairDock2023.cjs');
require('../../vc/crypto/Bls12381BBSSignatureDock2022.cjs');
require('../../vc/crypto/Bls12381G2KeyPairDock2022.cjs');
require('../../vc/crypto/Bls12381BBSSignatureDock2023.cjs');
require('../../vc/crypto/Bls12381BBSSignatureProofDock2022.cjs');
require('../../vc/crypto/Bls12381BBSSignatureProofDock2023.cjs');
require('../../vc/crypto/Bls12381BDDT16KeyPairDock2024.cjs');
require('../../vc/crypto/Bls12381BDDT16MACDock2024.cjs');
require('../../vc/crypto/Bls12381BDDT16MACProofDock2024.cjs');
require('../../vc/crypto/Bls12381PSKeyPairDock2023.cjs');
require('../../vc/crypto/Bls12381PSSignatureDock2023.cjs');
require('../../vc/crypto/Bls12381PSSignatureProofDock2023.cjs');
require('../../vc/crypto/EcdsaSecp256k1Signature2019.cjs');
require('../../vc/crypto/EcdsaSecp256k1VerificationKey2019.cjs');
require('@juanelas/base64');
require('../../keypairs/keypair-secp256k1.cjs');
require('elliptic');
require('../../keypairs/dock-keypair.cjs');
require('../../utils/encoding/multibase.cjs');
require('../../vc/crypto/Ed25519Signature2018.cjs');
require('../../vc/crypto/Ed25519VerificationKey2018.cjs');
require('../../keypairs/keypair-ed25519.cjs');
require('@stablelib/ed25519');
require('../../vc/crypto/Ed25519Signature2020.cjs');
require('../../vc/crypto/Ed25519VerificationKey2020.cjs');
require('../../vc/crypto/JsonWebSignature2020.cjs');
require('../../keypairs/did-keypair.cjs');
require('../did/onchain/did-key.cjs');
require('../offchain-signatures/params/index.cjs');
require('../offchain-signatures/params/value.cjs');
require('../generic/option.cjs');
require('../offchain-signatures/curve-type.cjs');
require('../offchain-signatures/params/id.cjs');
require('../generic/with-from-dock-id.cjs');
require('../offchain-signatures/public-keys/index.cjs');
require('../generic/with-prop.cjs');
require('../generic/with-props.cjs');
require('../offchain-signatures/public-keys/value.cjs');
require('../offchain-signatures/public-keys/ref.cjs');
require('../offchain-signatures/public-keys/id.cjs');
require('../did/onchain/verification-relationship.cjs');
require('../did/document/verification-method-ref-or-ident-ref.cjs');
require('../did/document/ident-ref.cjs');
require('../../vc/credentials.cjs');
require('../../vc/CredentialIssuancePurpose.cjs');
require('../../vc/schema.cjs');
require('jsonschema');
require('../../vc/constants.cjs');
require('../../vc/revocation.cjs');
require('blakejs');
require('../../utils/ident/ensure-ident.cjs');
require('../../utils/ident/matchers.cjs');
require('../did/index.cjs');
require('../did/offchain/index.cjs');
require('../did/offchain/doc-ref.cjs');
require('../did/onchain/index.cjs');
require('../did/onchain/controllers.cjs');
require('../did/onchain/verification-method-signature.cjs');
require('../did/document/index.cjs');
require('../did/document/service-endpoint.cjs');
require('../did/document/verification-method.cjs');
require('../../utils/encoding/base-58.cjs');
require('../generic/with-base58.cjs');
require('../generic/with-base58btc.cjs');
require('../generic/with-multibase.cjs');
require('../did/document/verification-method-type.cjs');
require('../did/document/verification-method-ref-or-cheqd-verification-method.cjs');
require('../did/document/const.cjs');
require('../../utils/mappings/dock-did-by-id.cjs');

class DockStatusListOrRevocationListCredential extends types_generic_withFrom(types_generic_typedEnum, (value, from) => {
  if (value instanceof vc_statusList2021Credential) {
    // eslint-disable-next-line no-use-before-define
    return new DockStatusList2021Credential(new types_statusListCredential_statusListCredentialValue(value));
  } else {
    return from(value);
  }
}) {}

class DockStatusList2021Credential extends DockStatusListOrRevocationListCredential {
  static Class = types_statusListCredential_statusListCredentialValue;

  static Type = 'statusList2021Credential';

  constructor(value) {
    super(utils_interfaces.maybeFrom(types_statusListCredential_statusListCredentialValue, value));
  }

  /**
   * Fail if the given verifiable credential id isn't a valid `StatusList2021Credential` id.
   * @param {*} id
   */
  static verifyID(id) {
    return this.Class.verifyID(id);
  }

  /**
   * Creates new `StatusList2021Credential` with supplied `id` and option `statusPurpose` = `revocation` by default,
   * `length` and `revokeIndices`. Note that credential with `statusPurpose` = `revocation` can't unsuspend its indices.
   * To allow unrevoking indices in the future, use `statusPurpose` = `suspension`.
   * The proof will be generated immediately using supplied `keyDoc`.
   *
   * @param {KeyDoc} keyDoc
   * @param {string} id - on-chain hex identifier for the `StatusList2021Credential`.
   * @param {object} [params={}]
   * @param {'revocation'|'suspension'} [params.statusPurpose=revocation] - `statusPurpose` of the `StatusList2021Credential`.
   * Can be either `revocation` or `suspension`.
   * @param {number} [params.length=1e4] - length of the underlying `StatusList`.
   * @param {Iterable<number>} [params.revokeIndices=[]] - iterable producing indices to be revoked or suspended initially
   * @returns {Promise<StatusList2021Credential>}
   */
  static async create(
    keyDoc,
    id,
    { statusPurpose = 'revocation', length = 1e4, revokeIndices = [] } = {},
  ) {
    return new this(
      await this.Class.create(keyDoc, id, {
        statusPurpose,
        length,
        revokeIndices,
      }),
    );
  }

  /**
   * Revokes indices and unsuspends other indices in the underlying status list, regenerating the proof.
   * If `statusPurpose` = `revocation`, indices can't be unsuspended.
   * The status list revoked (suspended)/unsuspended indices will be set atomically and in case of an error,
   * the underlying value won't be modified.
   * Throws an error if the underlying status list can't be decoded or any of the supplied indices is out of range.
   *
   * @param {KeyDoc} keyDoc
   * @param {object} [update={}]
   * @param {Iterable<number>} update.revokeIndices - indices to be revoked or suspended
   * @param {Iterable<number>} update.unsuspendIndices - indices to be unsuspended
   * @returns {Promise<this>}
   */
  async update(keyDoc, { revokeIndices = [], unsuspendIndices = [] }) {
    await this.value.update(keyDoc, { revokeIndices, unsuspendIndices });

    return this;
  }

  /**
   * Returns a `Promise` resolving to the decoded `StatusList`.
   *
   * @returns {Promise<StatusList>}
   */
  async decodedStatusList() {
    return await this.value.decodedStatusList();
  }

  /**
   * Returns `true` if given index is revoked or suspended, `false` otherwise.
   * Throws an error if the underlying status list can't be decoded or supplied index is out of range.
   *
   * @param {number} index
   * @returns {Promise<boolean>}
   */
  async revoked(index) {
    return await this.value.revoked(index);
  }

  /**
   * Accepts an iterable of indices to be checked and returns an array containing `true` in the positions
   * of revoked (suspended) indices and `false` for non-revoked (non-suspended) indices.
   * Throws an error if the underlying status list can't be decoded or any of supplied indices is out of range.
   *
   * @param {Iterable<number>} indices
   * @returns {Promise<Array<boolean>>}
   */
  async revokedBatch(indices) {
    return await this.value.revokedBatch(indices);
  }

  /**
   * Validates underlying `StatusList2021Credential`.
   */
  validate() {
    this.value.validate();
  }
}

DockStatusListOrRevocationListCredential.bindVariants(DockStatusList2021Credential);

exports.CheqdMainnetStatusListCredentialId = types_statusListCredential_id.CheqdMainnetStatusListCredentialId;
exports.CheqdStatusListCredentialId = types_statusListCredential_id.CheqdStatusListCredentialId;
exports.CheqdStatusListCredentialIdValue = types_statusListCredential_id.CheqdStatusListCredentialIdValue;
exports.CheqdTestnetStatusListCredentialId = types_statusListCredential_id.CheqdTestnetStatusListCredentialId;
exports.DockStatusListCredentialId = types_statusListCredential_id.DockStatusListCredentialId;
exports.DockStatusListCredentialIdValue = types_statusListCredential_id.DockStatusListCredentialIdValue;
exports.StatusListCredentialId = types_statusListCredential_id.StatusListCredentialId;
exports.DockStatusList2021Credential = DockStatusList2021Credential;
exports.DockStatusListOrRevocationListCredential = DockStatusListOrRevocationListCredential;
//# sourceMappingURL=index.cjs.map
