'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var types_did_onchain_constants = require('../constants.cjs');
require('../../../../utils/types/array.cjs');
var utils_types_bytes = require('../../../../utils/types/bytes.cjs');
require('bs58');
require('multiformats/bases/base58');
require('varint');
var utils_encoding_ss58 = require('../../../../utils/encoding/ss-58.cjs');
require('../../../generic/typed-enum.cjs');
var types_generic_typedBytes = 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');
var types_generic_sized = require('../../../generic/sized.cjs');
var types_generic_typedNumber = require('../../../generic/typed-number.cjs');
require('../../../generic/typed-set.cjs');
require('../../../generic/typed-map.cjs');
var types_generic_typedStruct = require('../../../generic/typed-struct.cjs');
require('uuid');
require('js-sha256');
var types_generic_withQualifier = require('../../../generic/with-qualifier.cjs');
var types_did_onchain_typedDid_signature = require('./signature.cjs');
require('../../../public-keys/public-key.cjs');
require('../../../public-keys/public-key-sr25519-value.cjs');
require('../../../public-keys/public-key-ed25519-value.cjs');
require('../../../public-keys/public-key-secp256k1-value.cjs');
require('../../../public-keys/public-key-x25519-value.cjs');
require('../../../signatures/signature-value.cjs');
var types_signatures_signature = require('../../../signatures/signature.cjs');
require('../../../../utils/inheritance.cjs');
require('../../../../utils/types/object.cjs');
require('../../../../utils/types/iterable.cjs');
require('../../../../utils/types/set.cjs');
require('crypto');
require('../../../../utils/interfaces.cjs');
require('../../../../utils/assert.cjs');
require('../../../../utils/error.cjs');
require('../../../../utils/types/string.cjs');
require('blake2b');
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.cjs');
require('../../../generic/with-from-json-bytes.cjs');
require('../../../generic/create-placeholder.cjs');
require('../../../../utils/types/number.cjs');
require('../../../../vc/crypto/constants.cjs');
require('../../../signatures/signature-ed25519-value.cjs');
require('../../../signatures/signature-secp256k1-value.cjs');
require('../../../signatures/signature-sr25519-value.cjs');

/**
 * `did:dock:*`
 */
class DockDidValue extends types_generic_sized(types_generic_withQualifier(types_generic_typedBytes)) {
  static Qualifier = types_did_onchain_constants.DockDIDQualifier;

  static Type = 'did';

  static Size = 32;

  static fromUnqualifiedString(did) {
    return new this(utils_types_bytes.isHex(did) ? did : utils_encoding_ss58.decodeFromSS58(did));
  }

  /**
   * Returns unqualified DID encoded as a `SS58` address.
   */
  toEncodedString() {
    return utils_encoding_ss58.encodeAsSS58(this.value);
  }

  signWith(keyPair, bytes) {
    // eslint-disable-next-line no-use-before-define
    return new DockDidSignature(
      // eslint-disable-next-line no-use-before-define
      new DockDidSignatureValue(this, keyPair.keyId, keyPair.sign(bytes)),
    );
  }
}

class DockDidSignatureValue extends types_generic_typedStruct {
  static Classes = {
    did: DockDidValue,
    keyId: class KeyId extends types_generic_typedNumber {},
    sig: types_signatures_signature.Signature,
  };
}

class DockDidSignature extends types_did_onchain_typedDid_signature {
  static Type = 'didSignature';

  static Class = DockDidSignatureValue;
}

exports.DockDidSignature = DockDidSignature;
exports.DockDidSignatureValue = DockDidSignatureValue;
exports.default = DockDidValue;
//# sourceMappingURL=dock-did-value.cjs.map
