'use strict';

require('../../utils/types/array.cjs');
require('crypto');
require('bs58');
require('multiformats/bases/base58');
require('varint');
require('../../utils/encoding/ss-58.cjs');
var utils_ident_parsers = require('../../utils/ident/parsers.cjs');
var resolver_did_didResolver = require('./did-resolver.cjs');
require('../../utils/inheritance.cjs');
require('../../utils/types/object.cjs');
require('../../utils/types/iterable.cjs');
require('../../utils/types/set.cjs');
require('blake2b');
require('../../utils/types/bytes.cjs');
require('../../utils/interfaces.cjs');
require('../../utils/assert.cjs');
require('../../utils/error.cjs');
require('../../utils/types/string.cjs');
require('../../utils/ident/matchers.cjs');
require('../../modules/abstract/did/module.cjs');
require('../../modules/abstract/common/abstract-api-provider.cjs');
require('../../modules/abstract/common/abstract-base-module.cjs');
require('../generic/resolver.cjs');
require('../generic/const.cjs');

/**
 * Class DIDResolverWithDIDReplacement extends DIDResolver.
 *
 * This class provides an implementation of the resolve method that replaces a specific did in a document if it does not match the didURL.
 * The replacement is done by parsing the document into JSON, finding and replacing all instances of 'doc.id' with 'did', and then converting it back to an object.
 */
class DIDResolverWithDIDReplacement extends resolver_did_didResolver {
  async resolve(didURL) {
    const { did } = utils_ident_parsers.parseDIDUrl(didURL);
    const doc = await super.resolve(did);

    if (doc.id !== did) {
      return JSON.parse(JSON.stringify(doc).split(doc.id).join(did));
    } else {
      return doc;
    }
  }
}

module.exports = DIDResolverWithDIDReplacement;
//# sourceMappingURL=did-resolver-with-did-replacement.cjs.map
