'use strict';

var resolver_generic_resolver = require('./resolver.cjs');
var resolver_generic_const = require('./const.cjs');
var resolver_utils = require('../utils.cjs');
require('../../utils/types/array.cjs');
require('../../utils/inheritance.cjs');
require('../../utils/types/object.cjs');
require('../../utils/types/iterable.cjs');
require('../../utils/types/set.cjs');
require('../../utils/types/string.cjs');
require('crypto');
require('bs58');
require('multiformats/bases/base58');
require('varint');
require('../../utils/encoding/ss-58.cjs');
require('blake2b');
require('../../utils/types/bytes.cjs');
require('../../utils/interfaces.cjs');
require('../../utils/assert.cjs');
require('../../utils/error.cjs');

/**
 * Creates a resolver.
 *
 * @template T
 * @param {Resolver<T> | function(string): Promise<T>} resolverOrFn
 * @param {object} [config={}]
 * @param {Array<string> | string | symbol} [config.prefix=WILDCARD]
 * @param {Array<string> | string | symbol} [config.method=WILDCARD]
 * @returns {Resolver<T> | ResolverRouter<T>}
 */
const createResolver = (
  resolverOrFn,
  { prefix = resolver_generic_const.WILDCARD, method = resolver_generic_const.WILDCARD } = {},
) => new (class ResolverCreatedUsingCreateResolver extends resolver_generic_resolver {
  prefix = prefix;

  method = method;

  constructor() {
    super();

    const isFn = typeof resolverOrFn === 'function';
    if (!isFn && resolverOrFn instanceof resolver_generic_resolver) {
      resolver_utils.ensureItemsAllowed(
        [].concat(resolverOrFn.prefix),
        [].concat(this.prefix),
        resolver_generic_const.WILDCARD,
      );
      resolver_utils.ensureItemsAllowed(
        [].concat(resolverOrFn.method),
        [].concat(this.method),
        resolver_generic_const.WILDCARD,
      );
    }

    this.resolve = isFn
      ? resolverOrFn
      : resolverOrFn.resolve.bind(resolverOrFn);
  }

  async resolve(_id) {
    throw new Error('Unimplemented');
  }
})();

exports.createResolver = createResolver;
//# sourceMappingURL=helpers.cjs.map
