import Resolver from './resolver.js';
import { WILDCARD } from './const.js';
import { ensureItemsAllowed } from '../utils.js';
import '../../utils/types/array.js';
import '../../utils/inheritance.js';
import '../../utils/types/object.js';
import '../../utils/types/iterable.js';
import '../../utils/types/set.js';
import '../../utils/types/string.js';
import 'crypto';
import 'bs58';
import 'multiformats/bases/base58';
import 'varint';
import '../../utils/encoding/ss-58.js';
import 'blake2b';
import '../../utils/types/bytes.js';
import '../../utils/interfaces.js';
import '../../utils/assert.js';
import '../../utils/error.js';

/**
 * 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 = WILDCARD, method = WILDCARD } = {},
) => new (class ResolverCreatedUsingCreateResolver extends Resolver {
  prefix = prefix;

  method = method;

  constructor() {
    super();

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

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

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

export { createResolver };
//# sourceMappingURL=helpers.js.map
